2 Replies Latest reply on Oct 22, 2007 7:48 AM by Nick201

    xml loop threw file

    Nick201
      How can I loop threw and display 2 records as separate and store into db. thanx

      <Row>
      <employee>
      <id>232</id>
      <firstname>Test1</firstname>
      <lastname>test2</lastname>
      </employee>
      <employee>
      <id>231</id>
      <firstname>Test1</firstname>
      <lastname>test2</lastname>
      </employee>
      </row>
        • 1. Re: xml loop threw file
          Hal B. Helms
          See if this helps:

          <cfxml variable="myXml">
          <row>
          <employee>
          <id>232</id>
          <firstname>Test1</firstname>
          <lastname>test2</lastname>
          </employee>
          <employee>
          <id>231</id>
          <firstname>Test1</firstname>
          <lastname>test2</lastname>
          </employee>
          </row>
          </cfxml>

          <cfoutput>


          <cfloop from="1" to="#ArrayLen(XmlSearch(myXml, '//employee'))#" index="i">
          <cfloop from="1" to="#ArrayLen(myXml.row.employee .xmlChildren)#" index="j">
          #myXml.row.employee
          .xmlChildren[j].xmlName# : #myXml.row.employee .xmlChildren[j].xmlText#<br />
          </cfloop>
          <hr />
          </cfloop>

          </cfoutput>
          • 2. Re: xml loop threw file
            Nick201 Level 1
            doesn't work . It is getting same output. If you put different value in firstname and lastname it is not getting correct result. it is getting same result even if you change value for first name and lastname in second time.