2010-11-22 68 views
0

忍无可忍,我是使用jQuery操作XML的新手。如何使用jQuery搜索多个XML节点的特定属性

说我有一个看起来像这样的XML文档:

<sitemap> 
    <products name="products" url="/products.html"> 
    <shirts name="women's shirts" url="/womens-shirts.html"> 
    <shoes name="women's shoe" url="/womens-shoes.html"> 
    <pants....> 
    </products> 
    <services> 
    <shopping> 
    <consultation> 
    </services> 
</sitemap> 

等,其中的每个子节点都具有一个名称和URL(我根据window.location的填充面包屑.pathname)。我想搜索一个特定的URL(它应该匹配您所在的任何页面),它可以位于父节点或子节点的任何节点中。如何在不指定我正在搜索的节点的情况下执行此操作?

谢谢!

回答

1

要指定任何元素名称,使用星号:

*[url='/products.html'] 
+0

感谢您的答复! – 2010-11-22 21:46:35