Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

XML validation checks on String

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do we perform XML validation checks on String. is there any method in java that can validate string
 
Marshal
Posts: 76492
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please explain more of what you want to know.
 
Manishkumar Modi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question is How do i perform XML Validation on String,
Detail : I have 1 string that contains tags, i want to check that string contains valid XML data or not...
 
Campbell Ritchie
Marshal
Posts: 76492
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need some sort of parser.
That is too difficult for "beginning", so I shall move you.
 
Sheriff
Posts: 22684
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of validation? Do you mean parsing XML documents against a DTD or XSD file?

For XSD validation it's actually not that hard. You first use SchemaFactory to create a Schema.
Next you create a DocumentBuilderFactory or SAXParserFactory, set the Schema and set validating on.
Next you use the DocumentBuilderFactory to create a DocumentBuilder, or the SAXParserFactory to create a SAXParser.
Finally, you use the DocumentBuilder or SAXParser to parse the XML document.
 
Manishkumar Modi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually i want to perform xhtml validation rules on string
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
xhtml is infinitely "extensible", in essence, by the x itself so named. I suppose you don't mean you've your own custom module extending the base of it?... xhtml validation is no difference from validating any schema/DTD backed xml document and the outline of how to do it is already pointed out.

If you mean you are not yet very agile in doing validating xml, I would say you can use many validating service out there such as this or any other you might come across after by googling.
http://validator.w3.org/#validate_by_input
You can cut-and-paste the "string" for the purpose or you can use the variation of validating via a url...
 
Marshal
Posts: 27379
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what's the problem exactly? Do you not know how to do XML validation? Or is that you know how to do that, but not if the XML is in a String?
 
Looky! I'm being abducted by space aliens! Me and this tiny ad!
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic