Dom Parser返回null

时间:2014-02-27 09:41:27

标签: xml saxparser domparser

我正在尝试解析xml字符串,我的xml看起来像这样:

xmlString=    <Resources>
    <Resource>
    <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:anyURI-equal">
    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">http://medico.com/record/patient/BartSimpson</AttributeValue><ResourceAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" DataType="http://www.w3.org/2001/XMLSchema#anyURI"/>
    </ResourceMatch>
    </Resource>
    </Resources>

我正在做以下事情:

DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xmlString));

Document doc = db.parse(is);

doc即将归零。

0 个答案:

没有答案