Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

How to check proper XML

Thread view: 
gk - 07 Feb 2006 17:50 GMT
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.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.