簡體   English   中英

如何使用jQuery搜索多個XML節點的特定屬性

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

忍受我,我是使用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(它應與您正在訪問的任何頁面匹配),該URL可以位於任何節點中,無論是父節點還是子節點。 如何在不指定要搜索的節點的情況下執行此操作?

謝謝!

要指定任何元素名稱,請使用星號:

*[url='/products.html']

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM