Professional Web Applications Themes

XML file and parsing - Coldfusion - Advanced Techniques

Hi all, We get quite a lot of XML files but this one is causing me major headaches. I need to p a xmpmetadata file, generated by Photoshop, into CF. The format if this file (cut bevause it is so big) is like: <xmpMetadata xmlns="http://xmlns.oracle.com/ord/meta/xmp" xsi:schemaLocation="http://xmlns.oracle.com/ord/meta/xmp http://xmlns.oracle.com/ord/meta/xmp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:exif="http://ns.adobe.com/exif/1.0/"> <exif:ColorSpace>1</exif:ColorSpace> </rdf:Description> <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:format>image/jpeg</dc:format> <dc:description> <rdf:Alt> <rdf:li xml:lang="x-default">456020.TIF</rdf:li> </rdf:Alt> </dc:description> <dc:subject> <rdf:Bag> <rdf:li>Keyword 1</rdf:li> <rdf:li>Keyword 2</rdf:li> <rdf:li>Keyword 3</rdf:li> </rdf:Bag> </dc:subject> <dc:creator> <rdf:Seq> <rdf:li>Nitai</rdf:li> </rdf:Seq> </dc:creator> </rdf:Description> Now what I need is to p different text from this doent. Problem is that I get about halfway ...

  1. #1

    Default XML file and parsing

    Hi all,

    We get quite a lot of XML files but this one is causing me major headaches. I
    need to p a xmpmetadata file, generated by Photoshop, into CF.

    The format if this file (cut bevause it is so big) is like:

    <xmpMetadata xmlns="http://xmlns.oracle.com/ord/meta/xmp"
    xsi:schemaLocation="http://xmlns.oracle.com/ord/meta/xmp
    http://xmlns.oracle.com/ord/meta/xmp"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <rdf:Description rdf:about="" xmlns:exif="http://ns.adobe.com/exif/1.0/">
    <exif:ColorSpace>1</exif:ColorSpace>
    </rdf:Description>
    <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <dc:format>image/jpeg</dc:format>
    <dc:description>
    <rdf:Alt>
    <rdf:li xml:lang="x-default">456020.TIF</rdf:li>
    </rdf:Alt>
    </dc:description>
    <dc:subject>
    <rdf:Bag>
    <rdf:li>Keyword 1</rdf:li>
    <rdf:li>Keyword 2</rdf:li>
    <rdf:li>Keyword 3</rdf:li>
    </rdf:Bag>
    </dc:subject>
    <dc:creator>
    <rdf:Seq>
    <rdf:li>Nitai</rdf:li>
    </rdf:Seq>
    </dc:creator>
    </rdf:Description>

    Now what I need is to p different text from this doent. Problem is that
    I get about halfway but I dont even get into the "bag" section to retrieve the
    keywords. This is my code:

    <cfset myxmlfile = expandpath("outgoing/text.xml")>
    <cffile action="read" file="#myxmlfile#" variable="thexmlcode">
    <cfset thexmlcode = trim(thexmlcode)>
    <cfset myxml = xmlp(thexmlcode)>
    <cfset xmeta = myxml.xmlroot>
    <cfset nrdesc = arraylen(xmeta.rdf.xmlchildren)>

    <cfoutput>
    <cfloop from="1" to="#nrdesc#" index="i">
    <cfset ardesc = xmeta.rdf.description.xmlchildren>
    <cfset nrdesc2 = arraylen(ardesc)>

    <cfloop from="1" to="#nrdesc2#" index="l">
    #ardesc[l].xmltext#<br>
    </cfloop>

    </cfloop>

    If any body could light up my drained brain I would appreciate it very much.


    nitai_co Guest

  2. #2

    Default Re: XML file and parsing

    Have you tried using XmlSearch() with an Xpath? (If you're unfamiliar with using XPath searches, www.zvon.org has some great resources).
    Hal Guest

  3. #3

    Default Re: XML file and parsing

    Hi

    Yes, I have tried it but to no success. I have had code like:

    <cfset xmsearch = xmlsearch(myxml, "//bag")>
    or
    ..within a loop..
    <cfset xmsearch = xmlsearch(myxml, "/xmpmetadata/rdf/description")>

    But I am propably not getting the hang off it .....

    nitai_co Guest

  4. #4

    Default Re: XML file and parsing

    Tried some more and if i do it like this:

    #myxml.xmpmetadata.rdf.description[1].colorspace.xmltext#

    then I get a result, but trying this like:

    xmlsearch(myxml, "//colorspace)

    I dont get anything.

    Any clues?

    Thank you.

    nitai_co Guest

Similar Threads

  1. parsing XML file
    By unknown in forum PHP Development
    Replies: 3
    Last Post: April 15th, 11:03 PM
  2. Parsing a txt file
    By Jari in forum PHP Development
    Replies: 2
    Last Post: January 6th, 09:21 PM
  3. HTML File Parsing
    By Raja Balaji R in forum ASP.NET General
    Replies: 1
    Last Post: August 3rd, 05:21 PM
  4. Help with parsing text file
    By Kent in forum PERL Miscellaneous
    Replies: 6
    Last Post: July 30th, 01:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139