2010-02-17 69 views

回答

4

XML的查詢語法稱爲XPath。

1

您可以使用E4XXPath來查詢您的XML文件。我建議使用新的E4X技術,因爲它比XPath更易於使用。

jQuery只提供標準的分層功能來解析XML文件(see here),因爲這不是他的目的。

2

我目前正在創建一種「jQuery port to Java」。它被稱爲jOOX,並將提供大部分jQuery的DOM導航和操作方法。除了簡單的選擇表達式語言,標準XPath和XML轉換是支持的,基於標準的Java DOM API

https://github.com/jOOQ/jOOX

一些示例代碼:

// Find the order at index for and add an element "paid" 
$(document).find("orders").children().eq(4) 
      .append("<paid>true</paid>"); 

// Find those orders that are paid and flag them as "settled" 
$(document).find("orders").children().find("paid") 
      .after("<settled>true</settled>");