[Simple-support] Ignore non-included elements and attributes
Brought to you by:
niallg
|
From: Dewitt, T. (317G) <Tyl...@jp...> - 2011-03-07 18:08:44
|
Hi all,
I'm working on a project that doesn't have an official schema and was wondering if there was a way that I could tell simpleXML to ignore any element contained in the XML that wasn't contained in my class definition (I'm using Java). Also, could I catch exceptions, particularly if I have defined an element in my Class structure that is then given to me as multiple elements in the XML (an inlined list)? I only need certain elements from the XML, and have those defined in my Java Classes.
For example:
I define:
Class Human{
@Element
Int age;
}
And am given:
<Human>
<age>30</age>
<height>70</height>
</Human>
Is there a way I can tell SimpleXML to grab the age element and ignore the height element? I know I can add in a required = false height element, but I don't know which elements the people generating the XML might throw at me.
Thanks!
Tyler
|