Re: [Simple-support] Ignore non-included elements and attributes
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-03-16 10:42:37
|
Persister.read(MyClass.class, inputStream, false)
--- On Mon, 7/3/11, Dewitt, Tyler (317G) <Tyl...@jp...> wrote:
From: Dewitt, Tyler (317G) <Tyl...@jp...>
Subject: [Simple-support] Ignore non-included elements and attributes
To: "sim...@li..." <sim...@li...>
Received: Monday, 7 March, 2011, 10:08 AM
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
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|