GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes Parsing a XML document for one particular element in XSD 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 "Parsing a XML document for one particular element in XSD" Watch "Parsing a XML document for one particular element in XSD" New topic
Author

Parsing a XML document for one particular element in XSD

Rajesh So
Ranch Hand

Joined: Oct 08, 2002
Posts: 141
Hello,

I have an XSD similar to the following lines.



where <XYZ> is the following.
<XYZ> has more elements, but I have pasted a crisp version in this thread. There can be a sequence of 'Child' elements in the XML file.



I am able to validate the XML file for this XSD. I am able to parse the FileInformation, User and ChildrenCount.
The legacy system I am working with some how picks up every child from the XML File. It presents the child as a String to me. I have to parse the child using the <xs:element name="Child"> and create a unmarshalled java object.
I have access to the XSD as File or urlOfXSD. The output should be of java type Child, an equivalent of Child element.
The following code does not understand the child string for the reason that it understands only the root element of an XSD. So I get a error as in the last of this thread.





My question is how to parse a string using a child element of an XSD? How to access the child element from urlOfXsd or XSD File ?

Thanks,
Rajesh
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 520
    
    3
My question is how to parse a string using a child element of an XSD? How to access the child element from urlOfXsd or XSD File ?

It is not clear whether you mean you want to unmarshal an xsd document or whether you want to unmarshal an instance of xml documents defined by such xsd.
The legacy system I am working with some how picks up every child from the XML File. It presents the child as a String to me. I have to parse the child using the <xs:element name="Child"> and create a unmarshalled java object.

You have to present an example of "child as a String". This will also clear up the ambiguity of the previous quote.
 
GeeCON Prague 2014
 
subject: Parsing a XML document for one particular element in XSD