0

I want to parse a XML file. It throws the Exception while creating object:

Document doc = builder.parse("Response.xml");

Exception:

[Fatal Error] Response.xml:63:67: The prefix "UDF" for element "UDF:RTSIDUDF.LIST" is not bound.
Exception in thread "main" org.xml.sax.SAXParseException: The prefix "UDF" for element "UDF:RTSIDUDF.LIST" is not bound.
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:180)
    at tallyreqandresponse.Ledger.main(Ledger.java:38)
Java Result: 1

Sample xml Code:

 <A>
 <LANGUAGENAME.LIST>
   <NAME.LIST TYPE="String">
       <NAME>ABC India (P) Ltd.,</NAME>
   </NAME.LIST>
   <LANGUAGEID TYPE="Number"> 1033</LANGUAGEID>
   <UDF:RTSIDUDF.LIST DESC="`RTSIDUDF`" ISLIST="YES" TYPE="Number">
       <UDF:RTSIDUDF DESC="`RTSIDUDF`"> 1387</UDF:RTSIDUDF>
   </UDF:RTSIDUDF.LIST>
   </LANGUAGENAME.LIST>
 </A>

Kindly help me out of it.

Edit Note: Added LANGUAGENAME.LIST Opening tag

1
  • 1
    You need xmlns with description of UDF namespace. Commented May 11, 2012 at 10:07

2 Answers 2

2

Your input markup is not namespace well-formed XML so it is rejected by the XML parser. You need to fix the input with e.g.

<A>
 <NAME.LIST TYPE="String">
       <NAME>ABC India (P) Ltd.,</NAME>
 </NAME.LIST>
 <LANGUAGEID TYPE="Number"> 1033</LANGUAGEID>
       <UDF:RTSIDUDF.LIST xmlns:UDF="http://example.com/" DESC="`RTSIDUDF`" ISLIST="YES" TYPE="Number">
                      <UDF:RTSIDUDF DESC="`RTSIDUDF`"> 1387</UDF:RTSIDUDF>
      </UDF:RTSIDUDF.LIST>
  </LANGUAGENAME.LIST>
</A>
Sign up to request clarification or add additional context in comments.

1 Comment

See w3.org/TR/REC-xml-names for the format specification. Also note that xmlns:UDF="http://example.com/" is meant as an example, I don't recognize your format so I can't relate a URL with it.
1

Beside the missing namespace definition it also seems that there is a mismatched tag:

</LANGUAGENAME.LIST> 

has no corresponding opening tag.

If you Google xml namespaces you get plenty of good links - have a look here for example.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.