简体   繁体   中英

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

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 specifying the node I am searching under?

Thanks!

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

*[url='/products.html']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM