Introduction to JAXP and Difference between JAXP and JAXB

Previous article was about the introduction to DOM. in this article i will focus on concept of handling XML data using DOM Parser in JAXP.

The Java API for XML Processing (JAXP) is for processing XML data using applications written in the Java programming language. JAXP leverages the parser standards Simple API for XML Parsing (SAX) and Document Object Model (DOM) so that you can choose to parse your data as a stream of events or to build an object representation of it. JAXP also supports the Extensible Stylesheet Language Transformations (XSLT) standard, giving you control over the presentation of the data and enabling you to convert the data to other XML documents or to other formats, such as HTML.

XML Processing in JAVA using DOM :
The Document Object Model (DOM) is a set of interfaces defined by the W3C DOM Working Group. It describes facilities for a programmatic representation of a parsed XML (or HTML) document.

XML Processing using DOM in JAXP
XML Processing using DOM in JAXP

XML Parsing Error: no element found

Few Days ago, i found strange error like “XML Parsing Error: no element found“.

I was unable to find the exact root cause. Most of the times it happens if you are missing any closing tag in your ASPZ application. I checked my complete page and reconfirmed but error still persist.

somehow i found that ASP.NET treat the response of page as XML document and that’s why we receive XML Parsing Error: no element found error.

so explicitly i set the response type of my page as text/HTML. Response.ContentType = “text/HTML”.

And this line tells the ASPX that page is HTML, not XML.