I couldn't agree with you more. I can't tell you the number of vendors
who fail to grasp the concepts and importance of primary and foreign
keys in databases. I think the right way is often detoured by someone
doing it the wrong way upstream... Hence the old addage, if you want
something done right, do it yourself. :)
Try this "example." It's not perfect, but it should get you started. I
think. Dump it in a file and run it. 
mf
 
<!--- this is a file called xml_test.cfm --->
<cfif isDefined("url.xml")>
<cfcontent type="text/xml" reset="true">
<feed>
<entry>
<title>A sample XML Child of "entry element"</title>
<link href="http://www.someplace.com"; />
<summary>Looks like greek to me. Looks like greek to me. Looks like
greek to me. Looks like greek to me. Looks like greek to me. Looks like
greek to me. Looks like greek to me. </summary>
<rm:id>852</rm:id>
<rm:image>http://www.someplace.com/img/user/442/852/4551594.jpg</rm:imag
e>
<rm:image>http://www.someplace.com/img/user/442/852/4551594a.jpg</rm:ima
ge>
<rm:image>http://www.someplace.com/img/user/442/852/4551594b.jpg</rm:ima
ge>
<rm:image>http://www.someplace.com/img/user/442/852/4551594c.jpg</rm:ima
ge>
<rm:image>http://www.someplace.com/img/user/442/852/4551594d.jpg</rm:ima
ge>
</entry>
</feed>
<cfabort>
</cfif>
<cfhttp url="http://iandev/ian/mf/xml_test.cfm?xml";
method="GET"></cfhttp>
<cfset xm = replace(cfhttp.fileContent,'rm:','rm','all')>
<cfscript>
selectedElements = XmlSearch(XmlParse(trim(xm)), "/feed/entry/"); 
txt1 = selectedElements[1]["rmimage"][1].XmlText; 
txt2 = selectedElements[1]["rmimage"][2].XmlText; 
</cfscript>
<cfoutput>
    First Child = #txt1#<br>
    Second Child = #txt2#<br>
</cfoutput>
<cfdump var="#selectedElements#">
<!--- end this is a file called xml_test.cfm --->

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Derrick
Peavy
Sent: Wednesday, June 11, 2008 4:39 PM
To: discussion@acfug.org
Subject: Re: [ACFUG Discuss] Need example - XML Import/parse help - 3
questions about sample data


Mark: 

Thank you! Yes, to all of that, I can do that, have done it. May resort
to that. But it's not the "right" way and I am trying hard to learn the
finer points of this. The problem is simply that I can't find an example
and even thinking outside the box seems to be of no use in solving the
problem. 

It makes me wonder, either the developers who do this in any language
keep the finer points to themselves, or there is a whole lot of
unnecessary re-writing and parsing of XML files going on across the web
- which defeats the whole point.  Just my thoughts. 


_____________ 
Derrick Peavy 
404-786-5036 
Sales and Web Services 
CollegeClassifieds.com 
http://www.collegeclassifieds.com 
A Service of Universal Advertising, inc. 
___________________________________ 


On Jun 11, 2008, at 4:21 PM, Fennell, Mark P. wrote:


        Is there no way to "normalize" (if that's the right term) the
XML? Granted, you'd have to be the one generating the XML, but it would
sure be nice to have rm:image1, rm:image2, etc. That would also give you
the ability to have descriptions for each of the images. 
        Barring that, and this isn't what you asked for, but I wonder if
you could read the file and write a new file and for each rm:image
change the name to rm:image#x# where x is some loop index value?
        Just random thoughts. I'll see if I can spawn an example for
you. :)
        mf

________________________________

        From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Derrick Peavy
        Sent: Wednesday, June 11, 2008 4:11 PM
        To: discussion@acfug.org
        Subject: Re: [ACFUG Discuss] Need example - XML Import/parse
help - 3 questions about sample data
        
        
        Steven, thank you. I did go through the W3School article after
you sent it as well as skimming the doc that Charlie sent. I actually
use that site a lot.  With your help, I solved the two small problems,
but the problem with duplicate children still plagues me. 
        

        At this point, i am back to my original question with perhaps a
more direct approach--- Can someone provide an example of accessing the
data within an XML file wherein a parent element has several exactly
named children. I still have not found the answer within the documents
or on line. 
        

        I appreciate the documentation that folks are sending - but I
also learn about, oh I don't know, maybe 1000X faster by seeing actual
code. But, that's just me.


        Example code, demonstrating my problem

        <feed>
        <entry>
        <title>A sample XML Child of "entry element"</title>
        <link href="http://www.someplace.com";></link>
        <summary>Looks like greek to me. Looks like greek to me. Looks
like greek to me. Looks like greek to me. Looks like greek to me. Looks
like greek to me. Looks like greek to me. </summary>
        <rm:id>852</rm:Id>
        
<rm:image>http://www.someplace.com/img/user/442/852/4551594.jpg</rm:imag
e>
        
<rm:image>http://www.someplace.com/img/user/442/852/4551594a.jpg</rm:ima
ge>
        
<rm:image>http://www.someplace.com/img/user/442/852/4551594b.jpg</rm:ima
ge>
        
<rm:image>http://www.someplace.com/img/user/442/852/4551594c.jpg</rm:ima
ge>
        
<rm:image>http://www.someplace.com/img/user/442/852/4551594d.jpg</rm:ima
ge>
        </entry>
        </feed>


        And parsing that type of structure into an array is no problem
EXPECT where the image is concerned. The following example works except
for the last array element [4]. If it worked, it would at least insert
the first instance of the rm:image child element. But nothing seems to
work.

        <cfscript>
        selectedElements = XmlSearch(XmlParse(trim(cfhttp.fileContent)),
"/feed/entry/"); 
        for (i = 1; i LTE ArrayLen(selectedElements); i = i + 1) 
        arrayImport[i][1] = selectedElements[i].summary.XmlText; 
        for (i = 1; i LTE ArrayLen(selectedElements); i = i + 1) 
        arrayImport[i][2] = selectedElements[i].link.XmlAttributes.href;

        for (i = 1; i LTE ArrayLen(selectedElements); i = i + 1) 
        arrayImport[i][3] = selectedElements[i]["rm:id"].XmlText; 
        for (i = 1; i LTE ArrayLen(selectedElements); i = i + 1) 
        arrayImport[i][4] = selectedElements[i]["rm:image"].XmlText; 
        </cfscript>


        So, documents and tutorials are always useful and appreciated,
but after 6 hours on this today, I think I would understand the problem
and solution much, much faster if someone out there had an actual
example to point to. Thanks!

        _____________ 
        Derrick Peavy 
        404-786-5036 
        Sales and Web Services 
        CollegeClassifieds.com 
        http://www.collegeclassifieds.com 
        A Service of Universal Advertising, inc. 
        ___________________________________ 


        On Jun 11, 2008, at 1:32 PM, Steven Ross wrote:


                I also recommend using the w3c xpath tutorial 

                when i forget syntax I always look there first...

                http://www.w3schools.com/XPath/default.asp
                
                
                On Wed, Jun 11, 2008 at 11:53 AM, Charlie Arehart
<[EMAIL PROTECTED]> wrote:
                

                        Derrick, besides Steven's useful replies to you
so far, since you said you were green with CF/XML processing, I can't
recommend highly enough that you spend 30 minutes reading this wonderful
guide:

                        
                         

                        Utilizing XML and XSLT in ColdFusion MX

        
http://www.adobe.com/devnet/coldfusion/articles/xmlxslt.pdf

                        
                         

                        Sure, it's 6 years old, and written for CF 6,
but it's a classic and all the info still applies. Just the best intro
to the whole subject I ever saw. Lots of examples, no presumption of
your knowing anything about XML, XSLT, XPATH, yet by the end of it's 30
pages you'll understand it all well enough to do nearly anything you'd
need. And, yes, it explains all those CFML variables, structures, and
functions you need to understand in order to process XML with CFML. 

                        
                         

                        I honestly wouldn't propose to try to help
someone with a question on the subject without strongly urging them to
read it first. It's that good, and thorough, and does a better job
explaining things than I ever could. :-)

                        
                         

                        /charlie

                        
                         

                        From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Derrick Peavy
                        Sent: Tuesday, June 10, 2008 11:31 PM
                        To: discussion@acfug.org
                        Subject: [ACFUG Discuss] XML Import/parse help -
3 questions about sample data


                         

                        I've been working with various XML documents,
importing them and then putting select data into a database. I am having
problems with new types of files and cannot seem to find an answer
(Google). Maybe I am not using the right terms when searching. But I
hope someone here can help. 


                         

                        For the most part, it's all straight forward. I
have been using this kind of code....


                         

                         

                        <cfscript>

                                    selectedElements =
XmlSearch(XmlParse(trim(cfhttp.fileContent)), "/feed/feed_item/");

                                    for (i = 1; i LTE
ArrayLen(selectedElements); i = i + 1) 

        
arrayImportRentMktCom[i][1] = selectedElements[i].summary.XmlText;

                                    for (i = 1; i LTE
ArrayLen(selectedElements); i = i + 1) 

        
arrayImportRentMktCom[i][2] = selectedElements[i].link.XmlText;

                                    for (i = 1; i LTE
ArrayLen(selectedElements); i = i + 1) 

        
arrayImportRentMktCom[i][3] = selectedElements[i].image.XmlText;

                        </cfscript>


                         

                         

                        However, I am pretty green with this type of
data handling when it's not a simple structure. The problem I am having
is when I encounter feeds with structures such as: 


                         

                        <feed>

                                    <feed_item>

                                                <item_id>1234</id>

                                                <link
href="somelink.html"/>

                                                <summary>Summary of the
item within the XML data structure that is being read.</summary>

        
<fn:image>http://www.someurl.com/img/pretty_pic_01.jpg</fn:image>

        
<fn:image>http://www.someurl.com/img/pretty_pic_02.jpg</fn:image>

        
<fn:image>http://www.someurl.com/img/pretty_pic_03.jpg</fn:image>

        
<fn:image>http://www.someurl.com/img/pretty_pic_04.jpg</fn:image>

                                    </feed_item>


                         

                         

                        1. When viewing the remote XML file using   ---
XmlParse(trim(cfhttp.fileContent))   ---  I see that the link is a
structure with an href element. How do you grab that data? 


                         

                        2. How do you deal with multiple child elements
with the same name?


                         

                        3. How do you deal with a colon in the element
name? 

                        
                         

                         

                        _____________ 

                        Derrick Peavy 

                        Sales and Web Services 

                        CollegeClassifieds.com 

                        http://www.collegeclassifieds.com 

                        A Service of Universal Advertising, inc. 

                        ___________________________________ 


                         

        
------------------------------------------------------------- 
                        To unsubscribe from this list, manage your
profile @ 
                        http://www.acfug.org?fa=login.edituserform 
                        
                        For more info, see
http://www.acfug.org/mailinglists 
                        Archive @
http://www.mail-archive.com/discussion%40acfug.org/ 
                        List hosted by FusionLink
<http://www.fusionlink.com>  
        
------------------------------------------------------------- 




                -- 
                Steven Ross
                web application & interface developer
                http://blog.stevensross.com
                [mobile] 404-488-4364 [fax] (404) 592-6885
                [ AIM / Yahoo! : zeriumsteven ] [googleTalk : nowhiding
] 

        
------------------------------------------------------------- 
                To unsubscribe from this list, manage your profile @ 
                http://www.acfug.org?fa=login.edituserform 
                
                For more info, see http://www.acfug.org/mailinglists 
                Archive @
http://www.mail-archive.com/discussion%40acfug.org/ 
                List hosted by FusionLink <http://www.fusionlink.com>  
        
------------------------------------------------------------- 



        ------------------------------------------------------------- 
        To unsubscribe from this list, manage your profile @ 
        http://www.acfug.org?fa=login.edituserform 
        
        For more info, see http://www.acfug.org/mailinglists 
        Archive @ http://www.mail-archive.com/discussion%40acfug.org/ 
        List hosted by FusionLink <http://www.fusionlink.com>  
        ------------------------------------------------------------- 





-------------------------------------------------------------

To unsubscribe from this list, manage your profile @ 

http://www.acfug.org?fa=login.edituserform



For more info, see http://www.acfug.org/mailinglists

Archive @ http://www.mail-archive.com/discussion%40acfug.org/

List hosted by http://www.fusionlink.com

-------------------------------------------------------------


Reply via email to