Accessing the XML inside an XPathNavigator object

  • Thread starter Thread starter JSheble
  • Start date Start date
J

JSheble

I'm integrating with a customer application, and in their assembly, when I
call a method it returns data to us as an XPathNavigator object. I can
parse the various elements I need out of this object with no problem, but
what I cannot seem to do is get at the actual XML string itself. For
accountability, tracking, auditing, and logging, I need to save the XML as
an XML file in an archive folder, but there doesn't seem to be any way of
getting at the actual XML itself.

Ideas? Suggestions?
 
JSheble said:
I'm integrating with a customer application, and in their assembly, when I
call a method it returns data to us as an XPathNavigator object. I can
parse the various elements I need out of this object with no problem, but
what I cannot seem to do is get at the actual XML string itself. For
accountability, tracking, auditing, and logging, I need to save the XML as
an XML file in an archive folder, but there doesn't seem to be any way of
getting at the actual XML itself.

It depends on what kind of XPathNavigator that is, if it is created over
an XmlDocument then you can cast and access the OuterXml (or InnerXml
depending on what you want):

XmlNode node = ((IHasXmlNode)xpathNavigator).GetNode();
// use node.OuterXml here

but if the XPathNavigator was created over an XPathDocument then that
cast is not possible.
 
Unfortunately I do not know nor control how it was created, the customers
assembly returns it. We've already told them we'd rather get an XmlDocument
object, or even better just the plain XML string itself, but they're
unwilling to change.

I'll try casting it out to see what I end up with... Thanx
 
Back
Top