[英]Picking a specific element when there is multiple elements of the same type on the page
[英]Accessing an element in an XML file that has multiple elements of the same type
以下是我的xml表格的樣本,您可以看到可能存在多種類型,演員,導演和公司。 我將如何具體訪問每一個。
最好用XPath和Java回答這個問題但是如果你不知道那些並得到答案那么告訴我你知道什么。
<?xml version="1.0" encoding="UTF-8"?>
<movies>
<movie>
<title>Seven</title>
<actor>Pitt</actor>
<director>Fincher</director>
<genre>action</genre>
<genre>drama</genre>
<year>1995</year>
<company>Cecchi_Gori_Pictures</company>
<grading>79</grading>
</movie>
</movies>
//read a nodelist using xpath
NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.