0 Replies Latest reply on Aug 6, 2007 9:23 AM by Newsgroup_User

    parse xml throws error on index i

    Level 7
      This code works like this
      <cfset temp = QuerySetCell(yahooxmlquery, "src",
      #xmldoc.rss.channel.item[1].xmlchildren[6].xmlattributes['url']#, #i#)>
      Not like this
      <cfset temp = QuerySetCell(yahooxmlquery, "src",
      #xmldoc.rss.channel.item .xmlchildren[6].xmlattributes['url']#, #i#)>
      It isn't resolving the index in the item ield.

      <cfoutput>
      <cfset xmlsource=" http://rss.news.yahoo.com/rss/topstories">
      <cfhttp url=#xmlsource# method="GET" resolveurl="No" ></cfhttp>
      <cfset xmldoc = XmlParse(CFHTTP.FileContent)>
      <cfset pb = xmldoc.rss.channel.item>
      <cfset size = ArrayLen(pb)>



      <cfset yahooxmlquery = QueryNew("title,link,src")>
      <cfset temp = QueryAddRow(yahooxmlquery, #size#)>
      <cfloop index="i" from = "1" to = #size#>
      <cfset temp = QuerySetCell(yahooxmlquery, "title",
      #xmldoc.rss.channel.item.title.xmltext#, #i#)>
      <cfset temp = QuerySetCell(yahooxmlquery, "link",
      #xmldoc.rss.channel.item.link.xmltext#, #i#)>
      <cfset temp = QuerySetCell(yahooxmlquery, "src",
      #xmldoc.rss.channel.item.xmlchildren[6].xmlattributes['url']#,
      #i#)> ------------Throws Error, no specifics

      <!--XML SOURCE <media:content
      url=" http://d.yimg.com/us.yimg.com/p/ap/20070805/capt.e954514282214be1a1991282a5e519af.mideast_ israel_palestinians_jrl104.jpg?x=130&amp;y=88&amp;sig=Dq4vuRzW9D7MyJD6kZk6Lw--"
      type="image/jpeg" height="88" width="130"/>--!>


      </cfloop>
      </cfoutput>
      <cfdump var=#yahooxmlquery#>


      XML Source
      <item>

      <title>Israeli, Palestinian leaders meet

      (AP)

      </title>

      <link> http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20070806/ap_on _re_mi_ea/israel_palestinians</link>

      <guid isPermaLink="false">ap/20070806/israel_palestinians</guid>

      <pubDate>Mon, 06 Aug 2007 13:16:14 GMT</pubDate>

      <description>&#60;p>&#60;a
      href=" http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20070806/ap_on _re_mi_ea/israel_palestinians">&#60;img
      src=" http://d.yimg.com/us.yimg.com/p/ap/20070805/capt.e954514282214be1a1991282a5e519af.mideast_ israel_palestinians_jrl104.jpg?x=130&amp;y=88&amp;sig=Dq4vuRzW9D7MyJD6kZk6Lw--"
      align="left" height="88" width="130" alt="Israeli Prime Minister Ehud Olmert
      pauses during the weekly cabinet meeting in Jerusalem, Sunday, Aug. 5, 2007.
      Olmert and the Palestinian President Mahmoud Abbas are to meet Monday in the
      West Bank to try narrowing their differences ahead of a planned peace
      conference in the United States, a Palestinian official said. (AP Photo/Gali
      Tibbon, Pool)" border="0" />&#60;/a>AP - Ehud Olmert on Monday became the
      first Israeli prime minister to visit a Palestinian town since the outbreak
      of fighting seven years ago, meeting under heavy guard with Palestinian
      President Mahmoud Abbas to talk about the creation of a Palestinian
      state.&#60;/p>&#60;br clear="all"/></description>

      ******<media:content
      url=" http://d.yimg.com/us.yimg.com/p/ap/20070805/capt.e954514282214be1a1991282a5e519af.mideast_ israel_palestinians_jrl104.jpg?x=130&amp;y=88&amp;sig=Dq4vuRzW9D7MyJD6kZk6Lw--"
      type="image/jpeg" height="88" width="130"/>

      <media:text type="html">&#60;p>&#60;a
      href=" http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20070806/ap_on _re_mi_ea/israel_palestinians">&#60;img
      src=" http://d.yimg.com/us.yimg.com/p/ap/20070805/capt.e954514282214be1a1991282a5e519af.mideast_ israel_palestinians_jrl104.jpg?x=130&amp;y=88&amp;sig=Dq4vuRzW9D7MyJD6kZk6Lw--"
      align="left" height="88" width="130" alt="photo" title="Israeli Prime
      Minister Ehud Olmert pauses during the weekly cabinet meeting in Jerusalem,
      Sunday, Aug. 5, 2007. Olmert and the Palestinian President Mahmoud Abbas are
      to meet Monday in the West Bank to try narrowing their differences ahead of
      a planned peace conference in the United States, a Palestinian official
      said. (AP Photo/Gali Tibbon, Pool)" border="0"/>&#60;/a>&#60;/p>&#60;br
      clear="all"/></media:text>

      <media:credit role="publishing company">(AP)</media:credit>

      </item>