具有连字符的Coldfusion XMLParse

时间:2013-03-29 23:22:03

标签: xml coldfusion xml-parsing coldfusion-9

我正在尝试从xml创建一个查询。我使用的是xmlparse,但主节点中有一个超级用户。我不确定如何构建它以便我可以遍历产品。这是它的样子

http://www.screencast.com/t/GhCgHTymMsR1

我一直在努力做到这一点,但它没有用,或者我错过了什么。

<cfset result = xmlParse(result.Filecontent)>
<cfloop index="x" from="1" to="#arrayLen(result["cj-api"]products.product)#">

<?xml version="1.0" encoding="UTF-8"?>
<cj-api>
  <products total-matched="363" records-returned="2" page-number="1">
    <product>
      <ad-id>10773572</ad-id>
      <advertiser-id>2955746</advertiser-id>
      <advertiser-name>Shopko</advertiser-name>
      <advertiser-category>picture books</advertiser-category>
      <buy-url>http://www.anrdoezrs.net/click-5917360-10773572?url=http%3A%2F%2Fshopko.com%2Fdetail%2FLEGO-Batman%3A-The-Visual-Book%2F48364%2F0000&amp;cjsku=48364</buy-url>
  <catalog-id>cjo:398</catalog-id>
  <currency>USD</currency>
  <description>Enter the world of your favorite LEGO&amp;#174; super hero in the first ever guide to LEGO&amp;#174; Batman&amp;#8482;! LEGO Batman: The Visual Dictionary combines DK's famous Visual Dictionary format with the adventurous world of the LEGO Caped Crusader.Every set and minifigure from the LEGO Batman universe will now be at your fingertips.</description>
  <image-url>http://shopko.com/items/shopko/images/small/48364_0000.jpg</image-url>
  <in-stock></in-stock>
  <isbn></isbn>
  <manufacturer-name></manufacturer-name>
  <manufacturer-sku></manufacturer-sku>
  <name>LEGO Batman: The Visual Book</name>
  <price>21.99</price>
  <retail-price>21.99</retail-price>
  <sale-price>21.99</sale-price>
  <sku>48364</sku>
  <upc></upc>
</product>
<product>
  <ad-id>10773572</ad-id>
  <advertiser-id>2955746</advertiser-id>
  <advertiser-name>Shopko</advertiser-name>
  <advertiser-category>toy figures &amp; playsets</advertiser-category>
  <buy-url>http://www.jdoqocy.com/click-5917360-10773572?url=http%3A%2F%2Fshopko.com%2Fdetail%2FLEGO-Friends-Olivias-Speedboat%2F59022%2F0000&amp;cjsku=59022</buy-url>
  <catalog-id>cjo:398</catalog-id>
  <currency>USD</currency>
  <description>All aboard for fun in the sun with Olivia's Speedboat!Includes Olivia mini-doll figure Features sand castle, shovel, bucket, beach towel, umbrella and cupBring the LEGO&amp;#174; Friends for a ride around the bay! Build a sand castle or relax in the sun!LEGO Friends pieces are fully compatible with all LEGO System bricks. Collect all of the LEGO Friends sets for a whole city of LEGO Friends fun!LEGO mini-dolls are figures made especially for the world of LEGO Friends, with thousands of customizable fashion and accessory combinations!Measures over 1&amp;#34; (4cm) tall, 4&amp;#34; (10cm) wide and 4&amp;#34; (12cm) long</description>
  <image-url>http://shopko.com/items/shopko/images/small/59022_0000.jpg</image-url>
  <in-stock></in-stock>
  <isbn></isbn>
  <manufacturer-name></manufacturer-name>
  <manufacturer-sku></manufacturer-sku>
  <name>LEGO Friends Olivias Speedboat</name>
  <price>13.49</price>
  <retail-price>14.99</retail-price>
  <sale-price>13.49</sale-price>
  <sku>59022</sku>
  <upc></upc>
    </product>
  </products>
</cj-api>

1 个答案:

答案 0 :(得分:0)

[摘自上述评论]

您的问题可能只是缺失.。而不是:

result["cj-api"]products.product 

尝试:

result["cj-api"].products.product