473,776 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing the XML inside an XPathNavigator object

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?
Nov 17 '05 #1
2 2896


JSheble wrote:
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)x pathNavigator). GetNode();
// use node.OuterXml here

but if the XPathNavigator was created over an XPathDocument then that
cast is not possible.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 17 '05 #2
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
"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..


JSheble wrote:
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)x pathNavigator). GetNode();
// use node.OuterXml here

but if the XPathNavigator was created over an XPathDocument then that cast
is not possible.
--

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

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3378
by: Craig Pearson | last post by:
Hi My function receives an XPathNavigator object. From here I need to build a DataSet to load into SQL Server (using SQLXML adaptor). Does anyone have an idea on the most efficient way to convert the XPathNavigator into a DataSet? Here is what I have at the moment: void function DoSomething( string xmlSchemeFile, System.Xml.XPath.XPathNavigator nav ) {
1
2167
by: Bruce Dunwiddie | last post by:
I'm trying to build a couple classes that would allow for writing xsl transforms against data that is not originally xml. I've got an xmlreader implementation that seems to work well. Based on some issues with it and transforms, I then wrapped it up in a custom xpathnavigator implementation. Everything works fine from the transform functionality perspective, but it's not scaling well to larger amounts of data, and I would like to find out...
7
4088
by: David Thielen | last post by:
Hi; Is there a way from an XPathNavigator object to get an xpath string that will, when used in a Select(xpath) on the underlying base/root XPathNavigator return the same XPathNavigator? In other words, I initially create an XPathNavigator for my entire xml document. To get an XPathNavigator object who's root is a given node in the original xml document, there is a unique xpath that will return that node. The unique xpath could have,...
4
17540
by: Andy Fish | last post by:
Hi, I can't figure out for the life of me how to select nodes using a namespace in XpathNavigator. For example: XPathDocument doc = new XPathDocument("file.xml"); XPathNavigator nav = doc.CreateNavigator(); XPathNodeIterator itr = nav.Select("/foo:bar"); Throws the exception "Namespace Manager or XsltContext needed. This query
2
1730
by: Steve | last post by:
Hi. I have ax xpath expression which returns a true or false. I don't know which method to use from the XPathNavigator object to get the result. There's not a ".SelectValue("xpath expression") method. Typically, I may use ..Select or .SelectSingleNode but I'm not returning a node or set of nodes? Maybe I shouldn't be using a XPathNavigator? Please let me know if you have any ideas. Thanks! -- Steve
3
2662
by: Vinayak Kamat | last post by:
Hi, I've an 'Employee' class. In my program this object is manipulated, children (List<T>) added, properties modified etc. Everytime this happens I want to be able to show some relevent html to the user. So I use XSLTransform. This Employee class is basically an XML serializable class produced out of an XML file when the program loads for the first time. Later on, if I've to show the modifications done to this object, I don't want to go...
4
4574
by: Daniel | last post by:
Is it possible to use regular expressions inside of an xpath statement executed by System.Xml.XmlDocument.SelectSingleNode() ? string sdoc = "<foo><bar a='1'/><bar a='2'/></foo>"; System.Xml.XmlDocument pdoc = new System.Xml.XmlDocument(); pdoc.LoadXml(sdoc); System.Xml.XmlNode pnode = pdoc.SelectSingleNode("//foo/bar/matches(.,'\\d')"); string foo = pnode.InnerText; int i23 = 23 + 23;
3
1290
by: David Thielen | last post by:
Hi; Two questions. I have an XPathNavigator object where it's OuterXml property is "<jan>231</jan>" and I am trying to write an xpath statement that will return the "jan". XPathNavigator nav = ...; 1) I can do nav.Evaluate("name(parent::*)"); and get "month". But if I do nav.Evaluate("name(self::*)"); I get "" returned. Shouldn't I get "jan"?
4
4404
by: Bruce Sandeman | last post by:
Hi, Does anyone know how to serialize an XPathNavigator object? I have tried the following but it moans that the xpn does not have a parameterless constructor. XPathNavigator xpn = e.Source.SelectSingleNode("/ns1:Invoice/ns1:InvoiceDetail/ns1:Lines/ns1:Line/ns1:Matches/ns1:Match/ns1:SubLedger", this.NamespaceManager); XmlSerializer x = new XmlSerializer(xpn.GetType()); StringWriter tw = new StringWriter();
0
9628
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10292
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.