2 Replies Latest reply on Jul 22, 2010 1:02 AM by Adam Cameron.

    XMLSearch difficulties

    hml398

      This is the XML i am trying to search:

       

      <sds:Student>
      <sds:Essays>
             <sds:EssayType>Overcoming adversity</sds:EssayType>
             <sds:EssayContent>one two three four five six seven eight nine  ten</sds:EssayContent>
          </sds:Essays>
      </sds:Student>

       

      I have tried both:

      <cfdump label="getthis" var="#XmlSearch(xmlDoc, "Student/Essays[EssayType='Overcoming adversity']")#" />

      and

      <cfdump label="getthis" var="#XmlSearch(xmlDoc,  "sds:Student/sds:Essays[sds:EssayType='Overcoming adversity']")#" />

       

      and nothing gets returned.    What am I doing wrong?

        • 1. Re: XMLSearch difficulties
          ilssac Level 5

          XML Namespaces and ColdFusion are a bit tricky to work with together.

           

          I'm affraid I don't do this enough to just spit out the solution.  But I know if you Google ColdFusion and XML Namespace you will get several very good blogs that discuss the in and outs as well as how to work with it.

           

          HTH

          Ian

          • 2. Re: XMLSearch difficulties
            Adam Cameron. Level 5

            Your first one won't work because you don't have your namespace in there, so it'd never match anything.

             

            However your second one works fine for me..?  Well: it returns Essays which have an EssayType text value of "Overcoming adversisy", which is what I expect you want.

             

            I'm running CF8... what are you on?

             

            PS: thanks pointing me in the direction of the [node='its text value'] thing. I didn't know one can do that.

             

            --

            Adam