public void Save(string filename, Node node) { FinalizeRootElement(node); Node.InternalAdjustPrefix(node.domNode, true); node.AdjustPrefix(); node.domNode.OwnerDocument.Save(filename); }
protected void FinalizeRootElement(Node node) { if (node.domNode.ParentNode.NodeType != XmlNodeType.DocumentFragment) return; if (rootElementName == null || rootElementName == "") throw new Exception("Call SetRootElementName first"); node.MakeRoot(namespaceURI, rootElementName, schemaLocation); DeclareNamespaces(node); }
protected abstract void DeclareNamespaces(Node node);
protected void DeclareNamespace(Node node, string prefix, string URI) { node.DeclareNamespace(prefix, URI); }
public void Save(string filename, Node node) { FinalizeRootElement(node); node.domNode.OwnerDocument.Save(filename); }
public Node(Node node) { domNode = node.domNode; }
protected XmlNode ReplaceDomElementAt(string URI, string name, int index, Node node) { node.domNode = CloneDomElementAs(URI, name, node); return domNode.ReplaceChild(node.domNode, GetDomChildAt(NodeType.Element, URI, name, index)); }
protected XmlNode InsertDomElementAt(string URI, string name, int index, Node node) { node.domNode = CloneDomElementAs(URI, name, node); return domNode.InsertBefore(node.domNode, GetDomChildAt(NodeType.Element, URI, name, index)); }
protected XmlElement CloneDomElementAs(string URI, string name, Node node) { XmlElement srcElement = (XmlElement)node.domNode; XmlElement dstElement = domNode.OwnerDocument.CreateElement(name, URI); XmlDocument doc = domNode.OwnerDocument; foreach (XmlAttribute attribute in srcElement.Attributes) dstElement.Attributes.Append((XmlAttribute)doc.ImportNode(attribute, false)); foreach (XmlNode childNode in srcElement.ChildNodes) dstElement.AppendChild(doc.ImportNode(childNode, true)); return dstElement; }
protected XmlNode AppendDomElement(string URI, string name, Node node) { node.domNode = CloneDomElementAs(URI, name, node); return domNode.AppendChild(node.domNode); }