在以下 XML 文档中...
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<x:Response xmlns:xcr="http:sefgvsefraerdv">
<folder id='82273' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns'http://srdefaredr/folders.xsd'>
<folder id='104018' name='account'/>
<folder id='104019' name='aaaaa'/>
<folder id='82277' name='Desktop' system='desktop'/>
<folder id='82278' name='Trashcan' system='trashcan'/>
<folder id='82279' name='Documents'>
<folder id='82280' name='Music'/>
<folder id='82281' name='Pictures'>
<folder id='82282' name='Nature Album'/>
</folder>
</folder>
<folder id='82283' name='Public' system='public'/>
<folder id='82284' name='music1'/>
<folder id='82286' name='music'>
<folder id='105744' name='abba'/>
</folder>
</folder>
</x:Response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我需要获取所有文件夹 ID 并打印它们。
例如,我是这样导航的:
xpath.evaluate( /*/*/*/*/*[5])
我将获取 Document 中的所有文件夹。从那我需要/*/*/*/*/*[5]/*
得到音乐和图片,/*/*/*/*/*[5]/*/*
只得到 Naturealbum。
然后一路返回/*/*/*/*/*[6]
并继续相同的..