This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes XML and Related Technologies and the fly likes Regular expression for valid xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Regular expression for valid xml" Watch "Regular expression for valid xml" New topic
Author

Regular expression for valid xml

Manishkumar Modi
Greenhorn

Joined: Sep 23, 2011
Posts: 14
i am looking regular expression to check string is valid XML or not
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

You should never do this. Instead, try to parse you'r xml to tell if it's valid or not.
Manishkumar Modi
Greenhorn

Joined: Sep 23, 2011
Posts: 14
Thank you. and can we make regular expression to check string is valid XHTML or not
Manishkumar Modi
Greenhorn

Joined: Sep 23, 2011
Posts: 14
I want to check this is valid or not
String myString = "<manish><abc pqr="1234"/></manish>";
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What you posted in neither well-formed nor valid XML.

Note that single regexps are not powerful enough to even check wellformedness of XML, much less validity (which implies the presence of some sort of schema).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regular expression for valid xml