First, I want to commend this group for the general helpfulness given to
new users. Many groups will dismiss questions from newbies as
bothersome. This group seems to be above that.
Now that I've greased my way in...
Here's a problem I'm trying to solve. I have a service that takes an
xml file in. I validate it against the schema. The data has a few
errors. I want to send only the good data along for more processing.
All I need to do is delete the bad elements. Sounds easy. My trouble
is knowing how to relate the error with the original file.
I have an XmlObject from parsing, and an XmlError object from
validating. The data looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<somedoc xmlns:xsi="com.somewhere.somedoc"
xsi:noNamespaceSchemaLocation='somedoc.xsd'>
<fileId>1234</fileId>
<userId>joeuser</userId>
<foobars>
<foo>
<somekey>123</somekey>
<someotherkey>456</someotherkey>
<someflag>Y</someflag>
<somedata>something</somedata>
<descriptions>
<description>desc 1</description>
<description>desc 2</description>
</descriptions>
</foo>
<foo>
<somekey>789</somekey>
<someotherkey>101112</someotherkey>
<someflag>Y</someflag>
<somedata>thisfieldistoolong</somedata>
<descriptions>
<description>desc 1</description>
<description>desc 2</description>
</descriptions>
</foo>
</foobars>
</somedoc>
I need to delete the foo element (and it's underlying children) since I
have one field with errors (<somedata>thisfieldistoolong</somedata>)
If I knew the index of foo that would be easy. I don't see how I can
get that from the XmlError.
Does anyone have an idea on this?
Thanks in advance,
Robert Costello