• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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: 79670
381
  • 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: 79670
381
  • 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: 22796
131
Eclipse IDE Spring 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: 28293
95
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?
 
Friends help you move. Good friends help you move bodies. This tiny ad will help:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic