2015-04-03 77 views
1

我想用JDOM瀏覽一個xml文件。 這裏的xml文件:用Jdom讀取一個xml文件

<?xml version="1.0" encoding= "UTF-8" ?> 
<definitions name="Web Service Mediation" 
targetNamespace="http://these-info.univ-tun.com/Web Service Mediation" 
xmlns="http://these-info.univ-tun.comstem online" > 
<binding name="ConnTWS" type="wsdlns:SimplePortType"> 
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
<operation name="soap"> 
<soap:operation soapAction="http://tempuri.org/action/binding.ConnTWS"/> 
</operation> 
</binding> 
</definitions> 

但是當我運行的類的.java,我有以下錯誤:

org.jdom.input.JDOMParseException: Error on line 6 of document file:/C:/Users/samsung/Desktop/copie%20de%20workspace/PluginFinal/plugin/eclipsehelio%20avec%20atl%20-%20Copie/workspace/Jdom2/Grammaire.xml: The prefix "soap" for element "soap:binding" is not bound. 
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:465) 
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:810) 
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:789) 
    at JDOM.main(JDOM.java:24) 
Caused by: org.xml.sax.SAXParseException: The prefix "soap" for element "soap:binding" is not bound. 

任何人都可以幫助糾正XML文件。 非常感謝。

+0

好的! 非常感謝:) – 2015-04-03 12:34:25

回答

1

您還沒有聲明soap命名空間。將xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"添加到您的定義屬性。像這樣:

<definitions name="Web Service Mediation" 
targetNamespace="http://these-info.univ-tun.com/Web Service Mediation" 
xmlns="http://these-info.univ-tun.comstem online" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">