我有一些看起来像这样的 XML:
<object-stream>
<manhattan:state id="1" turn="0" start="red" current="red" type="select">
<red id="2" displayName="Spieler 1" points="0">
<segment id="3" size="1" usable="0" retained="11"/>
<segment id="4" size="2" usable="0" retained="6"/>
<segment id="5" size="3" usable="0" retained="4"/>
<segment id="6" size="4" usable="0" retained="3"/>
<card id="7" slot="0"/>
<card id="8" slot="2"/>
<card id="9" slot="3"/>
<card id="10" slot="3"/>
</red>
<blue id="11" displayName="Spieler 2" points="0">
<segment id="12" size="1" usable="0" retained="11"/>
<segment id="13" size="2" usable="0" retained="6"/>
<segment id="14" size="3" usable="0" retained="4"/>
<segment id="15" size="4" usable="0" retained="3"/>
<card id="16" slot="3"/>
<card id="17" slot="4"/>
<card id="18" slot="4"/>
<card id="19" slot="4"/>
</blue>
</manhattan:state>
[...]
</object-stream>
我想要一个简单的 DOM 表示,但是当我尝试用 a 解析它时org.jdom.input.SAXBuilder
,它失败了:
Exception in thread "main" org.jdom.input.JDOMParseException: Error on line 2:
The prefix "manhattan" for element "manhattan:state" is not bound.
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:533)
[...]
我怎样才能使这项工作?