ASP.NET Web Service returning XML result and nodevalue is always null
Posted
by kburnsmt
on Stack Overflow
See other posts from Stack Overflow
or by kburnsmt
Published on 2010-05-25T21:56:18Z
Indexed on
2010/05/26
16:31 UTC
Read the original article
Hit count: 218
I have an ASP.NET web service which returns an XMLDocument. The web service is called from a Firefox extension using XMLHttpRequest.
var serviceRequest = new XMLHttpRequest(); serviecRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
I consume the result using responseXML. So far so good. But when I iterate through the XML I retrieve nodeValue - nodeValue is always null. When I check the nodeType the nodeType is type 1 (Node.ELEMENT_NODE == 1).
Node.NodeValue states all nodes of type Element will return null.
In my webservice I have created a string with the XML i.e. xml="Hank"
I then create the XmlDocument XmlDocument doc = new XmlDocument(); doc.LoadXML(string);
I know I can specify the nodetype using using CreateNode. But when I am just building the xml by appending string values is there a way to change the nodeType to Text so Node.nodeValue will be "content of the text node".
© Stack Overflow or respective owner