473,746 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLNode - XMLDocument types question

I have a web service method that returns an XMLDocument. The signature is:
public XmlDocument GetPOs()

The following client code calls this method but it accepts an XMLNode
instead of an XMLDocument and my first question is why does this work?
XmlNode neNode;
neNode = myHFCService.Ge tPOs();
DataSet myds = new DataSet();
byte[] buf =
System.Text.ASC IIEncoding.ASCI I.GetBytes(neNo de.OuterXml);
System.IO.Memor yStream ms = new System.IO.Memor yStream(buf);
myds.ReadXml(ms );
gvOrders.DataSo urce = myds.Tables[0];
Secondly, why does the following client code get a type mismatch?

XmlDocument myXMLDoc = new XmlDocument();
myXMLDoc = myHFCService.Ge tPOs();

The service is returning a type of XMLDocument but it comes back as XMLNode.
Those are different types.

Thanks,
Gary
Mar 10 '07 #1
5 3878
GaryDean wrote:
I have a web service method that returns an XMLDocument. The signature is:
public XmlDocument GetPOs()

The following client code calls this method but it accepts an XMLNode
instead of an XMLDocument and my first question is why does this work?
XmlNode neNode;
neNode = myHFCService.Ge tPOs();
DataSet myds = new DataSet();
byte[] buf =
System.Text.ASC IIEncoding.ASCI I.GetBytes(neNo de.OuterXml);
System.IO.Memor yStream ms = new System.IO.Memor yStream(buf);
myds.ReadXml(ms );
gvOrders.DataSo urce = myds.Tables[0];
Secondly, why does the following client code get a type mismatch?

XmlDocument myXMLDoc = new XmlDocument();
myXMLDoc = myHFCService.Ge tPOs();
XmlNode is the base class for all those specialized classes like
XmlElement or XmlDocument. When you get a piece of XML markup in the
SOAP response I think it is difficult to distinguish whether e.g
<element>conten t</element>
is the result of serializing an XmlDocument instance or an XmlElement
instance so you get an XmlNode as the common subclass.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 11 '07 #2
Hi Gary,
Thanks for Martin's reply.

Yes, as Martin said.
XmlDocument is derived from XmlNode. When XmlDocument objects are passed as
parameters to Web Service methods, or are returned from Web Service
methods, they are marshaled as XmlNode objects. This behavior is by design.

We suggest you may use XmlDocument API to load data from XMLNode.
For example:

XmlDocument myXMLDoc = new XmlDocument();
myXMLDoc.LoadXm l(myHFCService. GetPOs().OuterX ml);

For more information, you can reference the following KB.
http://support.microsoft.com/kb/330600/en-us

Please feel free to let me know if there is anything unclear. I'm glad to
assist you.

Hope this helps.
Sincerely,
Wen Yuan

Mar 12 '07 #3
Hi Gary,

I just want to check whether your issue has been resolved.
Please feel free to update here if it still persists. I'm glad to assist
you.

Have a great day,
Sincerely,
Wen Yuan

Mar 14 '07 #4
Wen Yuan,
sorry for so long to get back to you but I got busy on something else...

Yes your response and the associate docs explain this behavior.

thanks very much for the help!

--
Regards,
Gary Blakely
""WenYuan Wang"" <v-******@online.m icrosoft.comwro te in message
news:5l******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Gary,

I just want to check whether your issue has been resolved.
Please feel free to update here if it still persists. I'm glad to assist
you.

Have a great day,
Sincerely,
Wen Yuan

Mar 30 '07 #5
Hi Gary,

Thanks for your response.
I'm glad to assist you.:)

Have a great day,
Sincerely,
Wen Yuan

Apr 2 '07 #6

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

Similar topics

5
4689
by: Ian Williamson | last post by:
Greetings, I have seen this question posted a few times, but the answers have not helped me. I have used the program xsd.exe to generate several c# classes from a client provided xsd template. I now wish take a sizeable amount of data and create an xml file based on these classes. My intent is to use xmldocument to build up the xml and then stream it to a file. My
3
8116
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to run the class it gives an error that "System.Xml.XmlNode.XmlNode() is inaccessible due to its protection level". This error comes because XmlNode has not any public constructor. I found XmlNode has two constructor but both are private or friend...
3
3589
by: Siu | last post by:
Hi, I've loaded an XmlDocument from a file XML: this file has many similar XmlNode and it is difficult to select them by using SelectSingleNode of the object XmlDocument. I've this question: is it possible to identify each XmlNode of the XmlDocument by using an inner key or something like that ? I precise that I 'm not allowed to change the file XML, therefore I can't add any key element or attribute in each node.
5
5099
by: Paul | last post by:
Here I have the definition of an XmlNode which is a property (PayPreference) on my Customer class containing an enum describing how the customer will pay. <PayPerference xsi:type="a4:Customer+CustomerPayOptions" xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">cash</PayPerference> I now want to add this XmlNode to a different...
5
2139
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to run the class it gives an error that "System.Xml.XmlNode.XmlNode() is inaccessible due to its protection level". This error comes because XmlNode has not any public constructor. I found XmlNode has two constructor but both are private or friend...
0
950
by: jens Jensen | last post by:
Hello, I have built a client of a websevrice. I call a webmethod that takes an Xmldocument object and returns an Xmldocument object. When i add a refernce to this webservice on the client, then the input output types of my webmethod generated in the proxy class are changed to XmlNode. This mean, I get XmlNode as input argument instead of XmlDocument and the same for the return type. I'm using Vsual Studio 2005.
4
17550
by: jens Jensen | last post by:
Hello, I have built a client of a websevrice. I call a webmethod that takes an Xmldocument object and returns an Xmldocument object. When i add a refernce to this webservice on the client, then the input output types of my webmethod generated in the proxy class are changed to XmlNode. This mean, I get XmlNode as input argument instead of XmlDocument and the same for the return type. I'm using Vsual Studio 2005.
3
2881
by: Earl | last post by:
In VB.Net, the following declaration builds and executes with no exceptions: Dim XMLDoc As New XmlDocument Dim Node As XmlNode But in C#, the following (equivalent?!) returns the build error "XMLNode does not exist in the current context.": XmlDocument XMLDoc = new XmlDocument(); XmlNode Node = XMLNode;
1
3317
by: Andrus | last post by:
How to remove whole Xmlnode so that outer tags are also removed ? To reproduce, run the code. Observed result: <Query> <DataSourceName>DS1</DataSourceName> <QueryParameters> </QueryParameters>
0
9351
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
9286
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
9219
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
8229
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...
0
6062
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
4587
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
3294
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
2
2768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2200
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.