Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Friday, February 23, 2007

Preparing Dataset for XSLT

To apply XSLT on XML, the xsi namespace needs to be set. This is a way to set the namespace for an XML generated from Dataset.GetXml string xmlnsNS = "http://www.w3.org/2000/xmlns/"; string xsiNS = "http://www.w3.org/2001/XMLSchema-instance"; XmlDataDocument xmlDocument = new XmlDataDocument(); xmlDocument.LoadXml(ds.GetXml()); xmlDocument.InsertBefore(xmlDocument.CreateXmlDeclaration("1.0", "utf-8", "yes"), xmlDocument.DocumentElement); XmlAttribute attributeNode = xmlDocument.CreateAttribute("xmlns", "xsi", xmlnsNS); attributeNode.Value = xsiNS; xmlDocument.DocumentElement.SetAttributeNode(attributeNode); xmlDocument.Save("prepared.xml");