How do i extract data from an xml file and store them into data structures in my code to use them? I might be using java or c for my coding but i need to extract data from an xml file conveniently to go ahead
-
possible duplicate of Parsing XML files using CodeIgniter?raina77ow– raina77ow2012-10-10 11:48:39 +00:00Commented Oct 10, 2012 at 11:48
-
Needs to be retagged as java because the statement of posting says "I might be using java or c"Aravind.HU– Aravind.HU2012-10-10 11:50:54 +00:00Commented Oct 10, 2012 at 11:50
2 Answers
If your XML files have a corresponding schema (or schemas), then the easiest way is to use JAXB to generate Java classes that can be used for both marshallng (turning Java objects into XML) and unmarshalling (read XML into Java objects).
Even if you don't have a schema, it is still worthwhile, but in this case you have to manually create and annotate the Java classes that corresponds to your XML structure.
Comments
Well, as one of the possible options you can use SimpleXML, there is a great amount of documentation available on the official PHP website. Examples included.