私はJavaのDOMパーサを使用してXMLファイルを解析しています。文書 - タグの名前を名前で取得する方法
のは、私は、次のXML私は「なendPoint」の値を取得したい
<?xml version="1.0"?>
<config>
<dotcms>
<endPoint>ip</endPoint>
</dotcms>
</config>
</xml>
を持っているとしましょう。私は次のコードスニペットでそれを行うことができます。 (すでにDocumentBuilderで解析していると仮定して)
NodeList nodeList = this.doc.getElementByTagName("dotcms");
Node nValue = (Node) nodeList.item(0);
return nValue.getNodeValue();
フィールドの名前でフィールドの値を取得することはできますか?よう... ....
Node nValue = nodeList.getByName("endPoint")
このようなもの...?
//素晴らしい!それは有り難いです!短く、しかし有用な答え。 – Moon