开发者

How to search for specific attribute of multiple XML nodes with jQuery

开发者 https://www.devze.com 2023-01-26 04:12 出处:网络
Bear with me, I\'m new to manipulating XML using jQuery. Say I have an XML document that looks something like this:

Bear with me, I'm new to manipulating XML using jQuery.

Say I have an XML document that looks something like this:

<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>

etc., where each child node of has both a name and a URL (I'm populating a breadcrumb based on window.location.pathname). I want to search for a specific URL (it should match whatever page you're on), which can be in any node, either parent or child. How do I do this without specif开发者_运维百科ying the node I am searching under?

Thanks!


To specify any element name, use an asterisk:

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

精彩评论

暂无评论...
验证码 换一张
取 消