我将XML作为字符串,并且此XML字符串具有多个节点:例如4 billingDetail节点。如何解析字符串并再次将4个节点作为字符串输出?
我正在使用JAVA。我尝试使用马歇尔然后解组但是速度慢而且工作不正常
示例:
<?xml version="1.0" encoding="UTF_8" standalone="yes"?>
<StoreMessage xmlns="http://www.alo.com/feed">
<billingDetail>
<billingDetailId>987</billingDetailId>
<contextId>0</contextId>
<userId>
<pan>F0F8DJH348DJ</pan>
<contractSerialNumber>46446</contractSerialNumber>
</userId>
<declaredVehicleClass>A</declaredVehicleClass>
</billingDetail>
<billingDetail>
<billingDetailId>987</billingDetailId>
<contextId>0</contextId>
<userId>
<pan>F0F8DJH348DJ</pan>
<contractSerialNumber>46446</contractSerialNumber>
</userId>
<declaredVehicleClass>A</declaredVehicleClass>
</billingDetail>
<billingDetail>
<billingDetailId>987</billingDetailId>
<contextId>0</contextId>
<userId>
<pan>F0F8DJH348DJ</pan>
<contractSerialNumber>46446</contractSerialNumber>
</userId>
<declaredVehicleClass>A</declaredVehicleClass>
</billingDetail>
<billingDetail>
<billingDetailId>987</billingDetailId>
<contextId>0</contextId>
<userId>
<pan>F0F8DJH348DJ</pan>
<contractSerialNumber>46446</contractSerialNumber>
</userId>
<declaredVehicleClass>A</declaredVehicleClass>
</billingDetail>
</StoreMessage>
答案 0 :(得分:1)
答案 1 :(得分:0)
完成此
对于DOM-Parser: - http://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/
对于SAX-Parse: - http://www.mkyong.com/java/how-to-read-xml-file-in-java-sax-parser/
它将帮助您更好地理解并以简单的方式获取节点