473,589 Members | 2,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert XmlDocument to XpathDocument

Hi,

I've an object of XmlDocument, I need to pass it to some function which
takes XpathDocument object, How could I convert? There is not Conversion
Operator overload like that.

Your reply might help me a lot.

Thanks,
Fahad
Nov 12 '05 #1
5 12644


Fahad Ashfaque wrote:
I've an object of XmlDocument, I need to pass it to some function which
takes XpathDocument object, How could I convert? There is not Conversion
Operator overload like that.


You can save to a MemoryStream and then load from that stream e.g.
MemoryStream memStream = new MemoryStream();
xmlDocument.Sav e(memStream);
memStream.Posit ion = 0;
XPathDocument xPathDocument = new XPathDocument(m emStream);

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
but that would be parsed again would not that be ?

My document is 3 MB of size and it takes 4 Seconds for XmlDocument.Loa d()
to return.

Dont I have other choice ?

"Martin Honnen" wrote:


Fahad Ashfaque wrote:
I've an object of XmlDocument, I need to pass it to some function which
takes XpathDocument object, How could I convert? There is not Conversion
Operator overload like that.


You can save to a MemoryStream and then load from that stream e.g.
MemoryStream memStream = new MemoryStream();
xmlDocument.Sav e(memStream);
memStream.Posit ion = 0;
XPathDocument xPathDocument = new XPathDocument(m emStream);

--

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

Nov 12 '05 #3


Fahad Ashfaque wrote:
but that would be parsed again would not that be ?

My document is 3 MB of size and it takes 4 Seconds for XmlDocument.Loa d()
to return.

Dont I have other choice ?


Why do you start with an XmlDocument at all?
Which is the method you want to pass the document to, perhaps it has
some overload with a signature for an interface XmlDocument implements.
It is difficult to make suggestions without knowing more context.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #4
I need to pass it to XslTransform and get the output through StreamWriter.
"Martin Honnen" wrote:


Fahad Ashfaque wrote:
but that would be parsed again would not that be ?

My document is 3 MB of size and it takes 4 Seconds for XmlDocument.Loa d()
to return.

Dont I have other choice ?


Why do you start with an XmlDocument at all?
Which is the method you want to pass the document to, perhaps it has
some overload with a signature for an interface XmlDocument implements.
It is difficult to make suggestions without knowing more context.

--

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

Nov 12 '05 #5


Fahad Ashfaque wrote:
I need to pass it to XslTransform and get the output through StreamWriter.


XslTransform has a method Load that takes an IXPathNavigable which is
implemented by both XPathDocument as well as XmlDocument.
And the method Transform also takes an IXPathNavigable so there you can
pass in an XmlDocument as well.
So when using XslTransform there is no need to convert an XmlDocument to
an XPathDocument.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #6

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

Similar topics

1
4377
by: Ian Lawton | last post by:
Hi, in a C# app, I have an XPathDocument that looks similar to this: <row uniqueid="4234" /> <row uniqueid="4365" /> <row uniqueid="3124" /> <row uniqueid="9879" /> <row uniqueid="1332" /> <row uniqueid="4322" />
2
2481
by: Jim Lewis | last post by:
After everything I have read and some of my own testing I am convinced that XPathDocument are more efficient if you are only using XML for read only and not modifying the XML. However, I have been having problems doing same procedures I do with XPathDocuments in XPathDocuments. I have a configuration XML document, which holds all the configuration information for an application (see below sample). I extract the information from the...
1
2254
by: John A Grandy | last post by:
working with a local xml file. perform an xpath query and iterate through the resultset to build a virtual DataTable -- each DataRow composed of multiple attributes of each element in the xpath resultset ... is working with an XPathDocument faster than working with an XMLDocument ? if so , how much faster ?
2
6022
by: Graham Pengelly | last post by:
Hi I am trying to transform on System.Xml.XmlDocument into another using XslTransform without writing the object out to a file. I am guessing it should work something like this... public XmlDocument TransformXmlDoc(XmlDocument docToTransform, string xsltFilePath) { //load the xslt
1
1430
by: vikram | last post by:
How to create XPathDocument object from xmldocument object thanks
3
1437
by: Fahad Ashfaque | last post by:
Hi, I found the XSL Transformation through .NET too complex. The most simplest overload of System.Xml.Xsl.XslTransform is Transform(inputfile, outputfile), but this saves the result into file. I need to supply the XmlDocument object (with the source tree loaded) and receive the output in string. Traditionally I do this thing in very simple way which is as below: dom.load "xmldoc.xml" sdom.load "xsldoc.xsl"
1
10130
by: Greg Allen | last post by:
Is there a way to get line number information from an XmlDocument object? As I work with the various elements in the XmlDocument, I want to be able to refer to the line number. I found an article on extending the DOM, which seems to be exactly what I want, here: http://msdn2.microsoft.com/library/e3x60fe9(en-us,vs.80).aspx
5
5782
by: Ben R. | last post by:
Hi, Could someone explain the functional difference between these classes? From what I understand, xpathdocument is faster in some scenarios, but I'm not sure why. Further, why is it that the method of getting xml data into these two classes differs? (xmldocument uses the load method, whereas xpathdocument doesn't have this available and one must specify the path to the xml data in the constructor, or so it seems). Any help would be...
5
6275
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I've been trying to improve the performance of our xml handling, so I've been doing some timing tests lately and ran across something I thought odd - XPathDocument seems slightly slower than XmlDocument. I've run the tests several times and have tried to eliminate extraneous variables like disk access but every time, XPathDocument comes up slower by a few percent. I'd expected it to be faster since it's a read-only...
0
7931
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
8360
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8224
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...
0
6637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5731
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
3849
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2374
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
1
1461
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.