470,596 Members | 1,462 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Validate against Schema and enter Error tags

Hi guys,

I have an XML Schema and I am validation many XML files against the schema.
If successful, the files get transferred to another location. If not, then I
would like to add an error tag right after the corresponding XmlNode (in the
next line) specifying the error message.
I am currently validating using an XMLReader with XMLReaderSettings. I have
tried with a EventHandler for the Validation Errors or Warnings, but don't
get the current node I am in here. Another try was using the catch block to
get the element and/or attribute name of the error node. This works, but
then the reader does not advance anymore, since I had an exception...

Is there anyone out there who might be able to help here?

thanks,
Martin
Jul 30 '07 #1
3 2188
Thanks for the reply.
Is there also the possbility to get a pointer to the current node from the
XmlReader class? I would then store those pointers in a collection and after
having parsed the whole Xml file walk through the entries in my collection
and add <resulttags with detailed information right after the Nodes
specified in my collection.

Thanks,
Martin

"Martin Honnen" <ma*******@yahoo.deschrieb im Newsbeitrag
news:uR**************@TK2MSFTNGP06.phx.gbl...
Martin Eckart wrote:
>I have an XML Schema and I am validation many XML files against the
schema. If successful, the files get transferred to another location. If
not, then I would like to add an error tag right after the corresponding
XmlNode (in the next line) specifying the error message.
I am currently validating using an XMLReader with XMLReaderSettings. I
have tried with a EventHandler for the Validation Errors or Warnings, but
don't get the current node I am in here. Another try was using the catch
block to get the element and/or attribute name of the error node. This
works, but then the reader does not advance anymore, since I had an
exception...

XmlNode is an abstract class for the .NET DOM implementation. XmlReader is
independent of the DOM implementation, it is a fast, forwards only pull
parser. If you are using XmlReader and a ValidationEventHandler then you
can cast the sender object to the XmlReader and access the reader
properties like NodeType or Name.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Aug 1 '07 #2
Martin Eckart wrote:
I would like to convert all XMLNode objects representing XmlAttributes into
their parent element. Any suggestion on how to do this? node.ParentNode is
empty...
Each XmlAttribute node has a property OwnerElement:
<URL:http://msdn2.microsoft.com/en-us/library/System.Xml.XmlAttribute.OwnerElement.aspx>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 2 '07 #3
You are my man! Many thanks to you Martin! Resolved my issues step by step,
have a pretty neet solution now thanks to your help!!!

Cheers,
Martin

"Martin Honnen" <ma*******@yahoo.deschrieb im Newsbeitrag
news:eA**************@TK2MSFTNGP04.phx.gbl...
Martin Eckart wrote:
>I would like to convert all XMLNode objects representing XmlAttributes
into their parent element. Any suggestion on how to do this?
node.ParentNode is empty...

Each XmlAttribute node has a property OwnerElement:
<URL:http://msdn2.microsoft.com/en-us/library/System.Xml.XmlAttribute.OwnerElement.aspx>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Aug 2 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Aaron P Frenger | last post: by
1 post views Thread by QuantDev | last post: by
reply views Thread by Harold Putman | last post: by
6 posts views Thread by Jonny | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.