Below is a simple example of reading XML and instantiating generated XMLBeans object.
To process this sample XML message:
e.g.
String xml = "<personal-info>
<name>Robin</name>
<mobile>0917-0000000</mobile>
...
</personal-info>";
You can parse the XML and get element value.
<Generated XMLBeans class> xmlDocument= <Generated XMLBeans class>.Factory.parse(xml);
e.g.
try
{
PersonalInfoDocument xmlDocument= PersonalInfoDocument .Factory.parse(xml);
} catch (XmlException e)
{
e.printStackTrace();
}
xmlDocument.getName();
xmlDocument.getnMobile();
Below is an example on how to instantiate XMLBeans generated class:
<Generated XMLBeans class> xmlObject = <Generated XMLBeans class>.Factory.newInstance();
e.g.
CacheDocument cacheDoc = CacheDocument.Factory.newInstance();
No comments:
Post a Comment