aspose file tools*
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
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
 
Similar Threads
Alphabets only valitation
Regular Expression to check String is valid XHTML or not
Avoiding regular expression in XML Schema
Doubt on Regular Expression
How can I add error handling facilities to this code?