テキストコンテンツとしてXMLタグを読むXML解析は、私は、XMLファイルのこのサンプルを持って
pはセルの内容です..しかし、時々私は、コンテンツのXMLタグの内側に配置する必要があると<Cells>
<Cell row="1" column="1">p</Cell>
<Cells>
私はそれらをxmlタグではなくシンプルテキストとして読んでいきたいと思っています。
<Cells>
<Cell row="1" column="1">p</Cell>
<Cell row="2" column="2"><Cell></Cell>
<Cell row="3" column="3"></Cell></Cell>
<Cells>
どうすればいいですか?このXMLを読み込むには、私はそのようなものを使用します。
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("Cell");
cell = new String[nList.getLength()][4];
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
cell[temp][1] = eElement.getAttribute("row");
cell[temp][2] = eElement.getAttribute("column");
cell[temp][3] = eElement.getTextContent();
}
}
ので<セル> .... < /セル内部<セル>または< /セルを>読んでどのような方法がある>コンテンツとしてとXMLタグとしてではないのですか?
ありがとうございました!
「CDATA」を使用できます。 –
しかし、私はcan not変更xml ...私はCDATAは、私が間違っているXMLでdirecly cdataを書く場合にのみ動作すると思いますか? – Joseph
もちろん、XMLでタグを書き込むには、CDATAを使用する必要があります。それ以外の場合は、整形式のXMLにはなりません。 –