0

I have an XML file not valid, like this: Example:

<projects>
  <project id =BP001>
   <name>Banking Project</name>
   <start-date>Jan 10 1999</start-date>
   <end-date>Jan 10 2003</end-date>
</project>

project id =BP001 ==> project id ="BP001"

It must be like that allover the file. I'm using java and I want to do this to validate the file Any idea?

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
ATEF CHAREF
  • 387
  • 5
  • 8
  • 18
  • Searching your title on Google leads me to this question: http://stackoverflow.com/questions/6362926/xml-syntax-validation-in-java – Pradeep Simha Jul 21 '13 at 12:32
  • What exactly do you mean by "like that"? Also, wouldn't you rather fix the source that produces these invalid files instead of cleaning up that mess afterwards? – Tim Pietzcker Jul 21 '13 at 12:38
  • @TimPietzcker - he may not have that option; this could be produced from a business partner. – Eric Brown Jul 22 '13 at 06:58

1 Answers1

1

You describe it as an "XML file, not valid". It's better to think of it as a file that isn't XML. If you want to process files that aren't XML, then you'll need non-XML tools. In particular, you will need a parser that can handle the grammar to which these files conform. That means (a) you'll have to define this grammar, and (b) you'll have to write a parser for it.

This is a lot of work, and this is why using XML is a good thing; it means that people don't have to write their own parsers. Using something that's similar to XML but not actually XML means you don't get any of these benefits.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164