my application will get a XML and store in a String variable.
String variable="a big xml string";
i want to check whether it is a valid/proper XML or not.
How do i check ?
my XML has these tags .
Example XML
===========
<note>
<to>peru</to>
<from>sadu</from>
<heading>headline</heading>
<body>do it now</body>
</note>
this is sample XML.
Now, how to check at runtime whether i am having a valid/proper
XML(this means,contains above tags) in the String variable?
Oliver Wong - 07 Feb 2006 18:12 GMT
> my application will get a XML and store in a String variable.
>
[quoted text clipped - 20 lines]
> Now, how to check at runtime whether i am having a valid/proper
> XML(this means,contains above tags) in the String variable?
Write a schema (XSD file) or document definition (DTD file) that
describes the structure of your XML file, then use a Java parser which
performs validation as part of its parsing phase.
Here's a tutorial on writing XML schemas:
http://www.w3schools.com/schema/default.asp
- Oliver
Roedy Green - 08 Feb 2006 23:15 GMT
>my application will get a XML and store in a String variable.
>
[quoted text clipped - 3 lines]
>
>How do i check ?
You need a XSD or DTD to describe the format of your file.
See http://mindprod.com/jgloss/xml.html
for various verifiers.
There is source code for a simple-minded one posted at
http://mindprod.com/jgloss/jnlp.html
for verifying jnlp a flavour of XML using an XSD schema.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.