使用Xpath过滤

时间:2012-10-05 23:59:25

标签: xml xpath

目前我有这个XML文件:

<?xml version="1.0" encoding="UTF-8"?>
<productFeed>
        <product id="233004">
        <name><![CDATA[Van Bommel P2577]]></name>
        <description><![CDATA[Leren casual herensneaker met nopjes op de hiel van Van Bommel. Kleur: cognac.]]></description>
        <price><![CDATA[199.95]]></price>        <productURL>http://vanarendonk.cleafs.com/go?k=4upHUYcQalVXox0zikwnMgTagF73SwA5&amp;c=1190&amp;redirect=http%3A%2F%2Fwww%2Evanarendonk%2Enl%2Fheren%2FVan%2DBommel%2FP2577%2D%2FCognac%2F120%2E13%2E6</productURL>
        <imageURL><![CDATA[http://www.vanarendonk.nl/update/images/120.13.6/.tmp/tmb.MTIwLjEzLjZfMDEuanBn800733.jpg]]></imageURL>
        <additional>
            <category><![CDATA[schoen]]></category>
            <sub_category><![CDATA[heren]]></sub_category>
            <gender><![CDATA[heren]]></gender>
            <type><![CDATA[Sneakers]]></type>            <model><![CDATA[16102/02 751]]></model>            <brand><![CDATA[Van Bommel]]></brand>            <color><![CDATA[Cognac]]></color>            <topmaterial><![CDATA[Glad leer]]></topmaterial>            <insole><![CDATA[rubber]]></insole>                                    <size><![CDATA[41;42;42,5;43,5;44;45;46;47]]></size>            <size_UK><![CDATA[7,5;8;8,5;9,5;10;10,5;11;12]]></size_UK>            <image_1><![CDATA[http://www.vanarendonk.nl/update/images/120.13.6/.tmp/tmb.MTIwLjEzLjZfMDEuanBn480440.jpg]]></image_1>
<image_2><![CDATA[http://www.vanarendonk.nl/update/images/120.13.6/.tmp/tmb.MTIwLjEzLjZfMDIuanBn480440.jpg]]></image_2>
<image_3><![CDATA[http://www.vanarendonk.nl/update/images/120.13.6/.tmp/tmb.MTIwLjEzLjZfMDMuanBn480440.jpg]]></image_3>
<image_4><![CDATA[http://www.vanarendonk.nl/update/images/120.13.6/.tmp/tmb.MTIwLjEzLjZfMDQuanBn480440.jpg]]></image_4>
<image_5><![CDATA[http://www.vanarendonk.nl/update/images/120.13.6/.tmp/tmb.MTIwLjEzLjZfMDUuanBn480440.jpg]]></image_5>
<image_6><![CDATA[http://www.vanarendonk.nl/update/images/120.13.6/.tmp/tmb.MTIwLjEzLjZfMDYuanBn480440.jpg]]></image_6>
<image_7><![CDATA[http://www.vanarendonk.nl/update/images/120.13.6/.tmp/tmb.MTIwLjEzLjZfMDcuanBn480440.jpg]]></image_7>
<image_8><![CDATA[http://www.vanarendonk.nl/update/images/120.13.6/.tmp/tmb.MTIwLjEzLjZfMDguanBn480440.jpg]]></image_8>
            <delivery_costs><![CDATA[geen verzendkosten vanaf 75,00]]></delivery_costs>
            <delivery_time><![CDATA[3 days]]></delivery_time>
        </additional>
    </product>
        ... 
<productFeed>

我想在品牌上过滤此Feed。我试过了:

/productFeed/product[1]/additional[1][contains(brand,'BRANDNAME')]

但这并没有给我任何结果。

谁知道如何仅根据品牌名称过滤此Feed? 有没有简单的在线工具可以做到这一点?我自己搜索过但却找不到。

1 个答案:

答案 0 :(得分:1)

试试这个(它获得品牌中带有子串Pant的节点):

/productFeed/product/additional/brand[contains(.,'Pant')]