簡體   English   中英

(讀取並)從內部存儲解析XML文件

[英](Read and) Parse an XML file from Internal Storage

我在內部存儲中有大量* .xml文件。 我不是自己創建這些文件的,但是我需要使用它們。 它們的結構如下:

<?xml version="1.0" encoding="utf-16"?>
<ControlFrame xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
     xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <LandCode>31</LandCode>
     <LandName>Australia</LandName>
     <strFormat>Format35to45</strFormat>
     <bUseOverlay>true</bUseOverlay>
     ...
</ControlFrame>

用戶從列表中選擇一個*.xml文件,然后為正確的*.xml生成一個File對象。

接下來,我需要在*.xml文件中查詢LandCodebUseOverlay類的屬性。

我已經嘗試了所有方法,但是無法在Jellybean 4.3上運行。

我最好的方法是什么,如何實施?

我猜您需要的是XPath

XPath是XML路徑語言,是一種查詢語言,用於從XML文檔中選擇節點。

有一個javax.xml.xpath ,它允許您制作XPath表達式並檢索節點。

在旁邊:
如果您打算學習XPath,請使用Pimp我的XSLT

暫無
暫無

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

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