How do I write XML into XMLDocument?
-
Hi, I am currently returning an XmlDocument from a webservice using the following:
[OperationContract] [FaultContract(typeof(Anaqua.Domain.AnaquaServiceError))] [XmlSerializerFormat] public XmlDocument GetLawUpdateGenerationXML(short versionNum) { ///Code here to gets the xml from the db }
Then in my page that consumes the webservice I did the following:XmlDocument doc = (XmlDocument)svc.GetLawUpdateGenerationXML(internalVersionNumber);
However it is saying: Cannot convert type 'System.Xml.XmlElement' to 'System.Xml.XmlDocument' Now I think this is because of the serialization using[XmlSerializerFormat] So how would I go about reading the XML into and XML Document? Regards Paul Custance -
Hi, I am currently returning an XmlDocument from a webservice using the following:
[OperationContract] [FaultContract(typeof(Anaqua.Domain.AnaquaServiceError))] [XmlSerializerFormat] public XmlDocument GetLawUpdateGenerationXML(short versionNum) { ///Code here to gets the xml from the db }
Then in my page that consumes the webservice I did the following:XmlDocument doc = (XmlDocument)svc.GetLawUpdateGenerationXML(internalVersionNumber);
However it is saying: Cannot convert type 'System.Xml.XmlElement' to 'System.Xml.XmlDocument' Now I think this is because of the serialization using[XmlSerializerFormat] So how would I go about reading the XML into and XML Document? Regards Paul Custance -
Hi, I am currently returning an XmlDocument from a webservice using the following:
[OperationContract] [FaultContract(typeof(Anaqua.Domain.AnaquaServiceError))] [XmlSerializerFormat] public XmlDocument GetLawUpdateGenerationXML(short versionNum) { ///Code here to gets the xml from the db }
Then in my page that consumes the webservice I did the following:XmlDocument doc = (XmlDocument)svc.GetLawUpdateGenerationXML(internalVersionNumber);
However it is saying: Cannot convert type 'System.Xml.XmlElement' to 'System.Xml.XmlDocument' Now I think this is because of the serialization using[XmlSerializerFormat] So how would I go about reading the XML into and XML Document? Regards Paul CustanceIf you wish to append a child node to the document root of an already created XML file then be sure to have
using System.Xml;
then the following will add a node:XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("path to your xml file that already had a root document node"); XmlNode newXmlNode = xmlDoc.CreateElement("tagname"); newXmlNode.AppendChild(xmlDoc.CreateTextElement("The tag's text node Value")); xmlDoc.DocumentElement.AppendChild(newXmlNode);
-Spacix All your skynet questions[^] belong to solved