2 // System.Xml.XmlDocument
5 // Daniel Weber (daniel-weber@austin.rr.com)
6 // Kral Ferch <kral_ferch@hotmail.com>
7 // Jason Diamond <jason@injektilo.org>
8 // Miguel de Icaza (miguel@ximian.com)
9 // Duncan Mak (duncan@ximian.com)
10 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
12 // (C) 2001 Daniel Weber
13 // (C) 2002 Kral Ferch, Jason Diamond, Miguel de Icaza, Duncan Mak,
20 using System.Xml.XPath;
21 using System.Diagnostics;
22 using System.Collections;
24 using Mono.Xml.Native;
28 public class XmlDocument : XmlNode
32 XmlLinkedNode lastLinkedChild;
33 XmlNameTable nameTable;
34 string baseURI = String.Empty;
35 XmlImplementation implementation;
36 bool preserveWhitespace = false;
37 WeakReference reusableXmlTextReader;
43 public XmlDocument () : this (null, null)
47 protected internal XmlDocument (XmlImplementation imp) : this (imp, null)
51 public XmlDocument (XmlNameTable nt) : this (null, nt)
55 XmlDocument (XmlImplementation impl, XmlNameTable nt) : base (null)
57 implementation = (impl != null) ? impl : new XmlImplementation ();
58 nameTable = (nt != null) ? nt : implementation.internalNameTable;
59 AddDefaultNameTableKeys ();
65 public event XmlNodeChangedEventHandler NodeChanged;
67 public event XmlNodeChangedEventHandler NodeChanging;
69 public event XmlNodeChangedEventHandler NodeInserted;
71 public event XmlNodeChangedEventHandler NodeInserting;
73 public event XmlNodeChangedEventHandler NodeRemoved;
75 public event XmlNodeChangedEventHandler NodeRemoving;
81 public override string BaseURI {
87 // Used to read 'InnerXml's for its descendants at any place.
88 internal XmlTextReader ReusableReader {
90 if(reusableXmlTextReader == null)
91 reusableXmlTextReader = new WeakReference (null);
92 if(!reusableXmlTextReader.IsAlive) {
93 XmlTextReader reader = new XmlTextReader ((TextReader)null);
94 reusableXmlTextReader.Target = reader;
96 return (XmlTextReader)reusableXmlTextReader.Target;
100 public XmlElement DocumentElement {
102 XmlNode node = FirstChild;
104 while (node != null) {
105 if (node is XmlElement)
107 node = node.NextSibling;
110 return node != null ? node as XmlElement : null;
114 [MonoTODO("It doesn't have internal subset object model.")]
115 public virtual XmlDocumentType DocumentType {
117 foreach(XmlNode n in this.ChildNodes) {
118 if(n.NodeType == XmlNodeType.DocumentType)
119 return (XmlDocumentType)n;
125 public XmlImplementation Implementation {
126 get { return implementation; }
129 public override string InnerXml {
131 return base.InnerXml;
133 set { // reason for overriding
134 this.LoadXml (value);
138 public override bool IsReadOnly {
139 get { return false; }
142 internal override XmlLinkedNode LastLinkedChild {
144 return lastLinkedChild;
148 lastLinkedChild = value;
152 public override string LocalName {
153 get { return "#document"; }
156 public override string Name {
157 get { return "#document"; }
160 public XmlNameTable NameTable {
161 get { return nameTable; }
164 public override XmlNodeType NodeType {
165 get { return XmlNodeType.Document; }
168 internal override XPathNodeType XPathNodeType {
170 return XPathNodeType.Root;
174 public override XmlDocument OwnerDocument {
178 public bool PreserveWhitespace {
179 get { return preserveWhitespace; }
180 set { preserveWhitespace = value; }
183 internal override string XmlLang {
184 get { return String.Empty; }
188 public virtual XmlResolver XmlResolver {
189 set { throw new NotImplementedException (); }
192 internal override XmlSpace XmlSpace {
194 return XmlSpace.None;
202 [MonoTODO("Should BaseURI be cloned?")]
203 public override XmlNode CloneNode (bool deep)
205 XmlDocument doc = implementation.CreateDocument ();
206 doc.PreserveWhitespace = PreserveWhitespace; // required?
209 foreach(XmlNode n in ChildNodes)
210 doc.AppendChild (doc.ImportNode (n, deep));
215 public XmlAttribute CreateAttribute (string name)
217 return CreateAttribute (name, String.Empty);
220 public XmlAttribute CreateAttribute (string qualifiedName, string namespaceURI)
225 ParseName (qualifiedName, out prefix, out localName);
227 return CreateAttribute (prefix, localName, namespaceURI);
230 public virtual XmlAttribute CreateAttribute (string prefix, string localName, string namespaceURI)
232 if ((localName == null) || (localName == String.Empty))
233 throw new ArgumentException ("The attribute local name cannot be empty.");
235 return new XmlAttribute (prefix, localName, namespaceURI, this);
238 public virtual XmlCDataSection CreateCDataSection (string data)
240 return new XmlCDataSection (data, this);
243 public virtual XmlComment CreateComment (string data)
245 return new XmlComment (data, this);
249 protected internal virtual XmlAttribute CreateDefaultAttribute (string prefix, string localName, string namespaceURI)
251 throw new NotImplementedException ();
254 public virtual XmlDocumentFragment CreateDocumentFragment ()
256 return new XmlDocumentFragment (this);
259 public virtual XmlDocumentType CreateDocumentType (string name, string publicId,
260 string systemId, string internalSubset)
262 return new XmlDocumentType (name, publicId, systemId, internalSubset, this);
265 public XmlElement CreateElement (string name)
267 return CreateElement (name, String.Empty);
270 public XmlElement CreateElement (
271 string qualifiedName,
277 ParseName (qualifiedName, out prefix, out localName);
279 return CreateElement (prefix, localName, namespaceURI);
282 public virtual XmlElement CreateElement (
287 if ((localName == null) || (localName == String.Empty))
288 throw new ArgumentException ("The local name for elements or attributes cannot be null or an empty string.");
289 CheckName (localName);
290 return new XmlElement (prefix != null ? prefix : String.Empty, localName, namespaceURI != null ? namespaceURI : String.Empty, this);
293 public virtual XmlEntityReference CreateEntityReference (string name)
295 return new XmlEntityReference (name, this);
299 internal protected virtual XPathNavigator CreateNavigator (XmlNode node)
301 throw new NotImplementedException ();
304 public virtual XmlNode CreateNode (
305 string nodeTypeString,
309 return CreateNode (GetNodeTypeFromString (nodeTypeString), name, namespaceURI);
312 public virtual XmlNode CreateNode (
317 string prefix = null;
318 string localName = name;
320 if ((type == XmlNodeType.Attribute) || (type == XmlNodeType.Element) || (type == XmlNodeType.EntityReference))
321 ParseName (name, out prefix, out localName);
323 return CreateNode (type, prefix, localName, namespaceURI);
326 public virtual XmlNode CreateNode (
333 case XmlNodeType.Attribute: return CreateAttribute (prefix, name, namespaceURI);
334 case XmlNodeType.CDATA: return CreateCDataSection (null);
335 case XmlNodeType.Comment: return CreateComment (null);
336 case XmlNodeType.Document: return new XmlDocument (); // TODO - test to see which constructor to use, i.e. use existing NameTable or not.
337 case XmlNodeType.DocumentFragment: return CreateDocumentFragment ();
338 case XmlNodeType.DocumentType: return CreateDocumentType (null, null, null, null);
339 case XmlNodeType.Element: return CreateElement (prefix, name, namespaceURI);
340 case XmlNodeType.EntityReference: return CreateEntityReference (null);
341 case XmlNodeType.ProcessingInstruction: return CreateProcessingInstruction (null, null);
342 case XmlNodeType.SignificantWhitespace: return CreateSignificantWhitespace (String.Empty);
343 case XmlNodeType.Text: return CreateTextNode (null);
344 case XmlNodeType.Whitespace: return CreateWhitespace (String.Empty);
345 case XmlNodeType.XmlDeclaration: return CreateXmlDeclaration ("1.0", null, null);
346 default: throw new ArgumentOutOfRangeException(String.Format("{0}\nParameter name: {1}",
347 "Specified argument was out of the range of valid values", type.ToString ()));
351 public virtual XmlProcessingInstruction CreateProcessingInstruction (
355 return new XmlProcessingInstruction (target, data, this);
358 public virtual XmlSignificantWhitespace CreateSignificantWhitespace (string text)
360 foreach (char c in text)
361 if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
362 throw new ArgumentException ("Invalid whitespace characters.");
364 return new XmlSignificantWhitespace (text, this);
367 public virtual XmlText CreateTextNode (string text)
369 return new XmlText (text, this);
372 public virtual XmlWhitespace CreateWhitespace (string text)
374 foreach (char c in text)
375 if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
376 throw new ArgumentException ("Invalid whitespace characters.");
378 return new XmlWhitespace (text, this);
381 public virtual XmlDeclaration CreateXmlDeclaration (string version, string encoding,
384 if (version != "1.0")
385 throw new ArgumentException ("version string is not correct.");
387 if ((standalone != null && standalone != String.Empty) && !((standalone == "yes") || (standalone == "no")))
388 throw new ArgumentException ("standalone string is not correct.");
390 return new XmlDeclaration (version, encoding, standalone, this);
394 public virtual XmlElement GetElementById (string elementId)
396 throw new NotImplementedException ();
399 public virtual XmlNodeList GetElementsByTagName (string name)
401 ArrayList nodeArrayList = new ArrayList ();
402 this.searchNodesRecursively (this, name, nodeArrayList);
403 return new XmlNodeArrayList (nodeArrayList);
406 private void searchNodesRecursively (XmlNode argNode, string argName,
407 ArrayList argArrayList)
409 XmlNodeList xmlNodeList = argNode.ChildNodes;
410 foreach (XmlNode node in xmlNodeList){
411 if (node.Name.Equals (argName))
412 argArrayList.Add (node);
414 this.searchNodesRecursively (node, argName, argArrayList);
418 private void searchNodesRecursively (XmlNode argNode, string argName, string argNamespaceURI,
419 ArrayList argArrayList)
421 XmlNodeList xmlNodeList = argNode.ChildNodes;
422 foreach (XmlNode node in xmlNodeList){
423 if (node.LocalName.Equals (argName) && node.NamespaceURI.Equals (argNamespaceURI))
424 argArrayList.Add (node);
426 this.searchNodesRecursively (node, argName, argNamespaceURI, argArrayList);
430 public virtual XmlNodeList GetElementsByTagName (string localName, string namespaceURI)
432 ArrayList nodeArrayList = new ArrayList ();
433 this.searchNodesRecursively (this, localName, namespaceURI, nodeArrayList);
434 return new XmlNodeArrayList (nodeArrayList);
437 private XmlNodeType GetNodeTypeFromString (string nodeTypeString)
439 switch (nodeTypeString) {
440 case "attribute": return XmlNodeType.Attribute;
441 case "cdatasection": return XmlNodeType.CDATA;
442 case "comment": return XmlNodeType.Comment;
443 case "document": return XmlNodeType.Document;
444 case "documentfragment": return XmlNodeType.DocumentFragment;
445 case "documenttype": return XmlNodeType.DocumentType;
446 case "element": return XmlNodeType.Element;
447 case "entityreference": return XmlNodeType.EntityReference;
448 case "processinginstruction": return XmlNodeType.ProcessingInstruction;
449 case "significantwhitespace": return XmlNodeType.SignificantWhitespace;
450 case "text": return XmlNodeType.Text;
451 case "whitespace": return XmlNodeType.Whitespace;
453 throw new ArgumentException(String.Format("The string doesn't represent any node type : {0}.", nodeTypeString));
457 [MonoTODO("default attributes (of imported doc); Entity; Notation")]
458 public virtual XmlNode ImportNode (XmlNode node, bool deep)
460 switch(node.NodeType)
462 case XmlNodeType.Attribute:
464 XmlAttribute src_att = node as XmlAttribute;
465 XmlAttribute dst_att = this.CreateAttribute (src_att.Prefix, src_att.LocalName, src_att.NamespaceURI);
466 dst_att.Value = src_att.Value; // always explicitly specified (whether source is specified or not)
470 case XmlNodeType.CDATA:
471 return this.CreateCDataSection (node.Value);
473 case XmlNodeType.Comment:
474 return this.CreateComment (node.Value);
476 case XmlNodeType.Document:
477 throw new XmlException ("Document cannot be imported.");
479 case XmlNodeType.DocumentFragment:
481 XmlDocumentFragment df = this.CreateDocumentFragment ();
484 foreach(XmlNode n in node.ChildNodes)
486 df.AppendChild (this.ImportNode (n, deep));
492 case XmlNodeType.DocumentType:
493 throw new XmlException ("DocumentType cannot be imported.");
495 case XmlNodeType.Element:
497 XmlElement src = (XmlElement)node;
498 XmlElement dst = this.CreateElement (src.Prefix, src.LocalName, src.NamespaceURI);
499 foreach(XmlAttribute attr in src.Attributes)
501 if(attr.Specified) // copies only specified attributes
502 dst.SetAttributeNode ((XmlAttribute)this.ImportNode (attr, deep));
503 if(DocumentType != null)
505 // TODO: create default attribute values
510 foreach(XmlNode n in src.ChildNodes)
511 dst.AppendChild (this.ImportNode (n, deep));
516 case XmlNodeType.EndElement:
517 throw new XmlException ("Illegal ImportNode call for NodeType.EndElement");
518 case XmlNodeType.EndEntity:
519 throw new XmlException ("Illegal ImportNode call for NodeType.EndEntity");
521 case XmlNodeType.Entity:
522 throw new NotImplementedException (); // TODO
524 case XmlNodeType.EntityReference:
525 return this.CreateEntityReference (node.Name);
527 case XmlNodeType.None:
528 throw new XmlException ("Illegal ImportNode call for NodeType.None");
530 case XmlNodeType.Notation:
531 throw new NotImplementedException (); // TODO
533 case XmlNodeType.ProcessingInstruction:
534 XmlProcessingInstruction pi = node as XmlProcessingInstruction;
535 return this.CreateProcessingInstruction (pi.Target, pi.Data);
537 case XmlNodeType.SignificantWhitespace:
538 return this.CreateSignificantWhitespace (node.Value);
540 case XmlNodeType.Text:
541 return this.CreateTextNode (node.Value);
543 case XmlNodeType.Whitespace:
544 return this.CreateWhitespace (node.Value);
546 case XmlNodeType.XmlDeclaration:
547 XmlDeclaration srcDecl = node as XmlDeclaration;
548 return this.CreateXmlDeclaration (srcDecl.Version, srcDecl.Encoding, srcDecl.Standalone);
551 throw new NotImplementedException ();
555 public virtual void Load (Stream inStream)
557 Load (new XmlTextReader (new XmlStreamReader (inStream)));
560 public virtual void Load (string filename)
562 Load (new XmlTextReader (filename));
565 public virtual void Load (TextReader txtReader)
567 Load (new XmlTextReader (txtReader));
570 public virtual void Load (XmlReader xmlReader)
572 // Reset our document
573 // For now this just means removing all our children but later this
574 // may turn out o need to call a private method that resets other things
575 // like properties we have, etc.
578 // create all contents with use of ReadNode()
580 XmlNode n = ReadNode (xmlReader);
586 public virtual void LoadXml (string xml)
588 XmlReader xmlReader = new XmlTextReader (new StringReader (xml));
592 internal void onNodeChanged (XmlNode node, XmlNode Parent)
594 if (NodeChanged != null)
595 NodeChanged (node, new XmlNodeChangedEventArgs
596 (XmlNodeChangedAction.Change,
597 node, Parent, Parent));
600 internal void onNodeChanging(XmlNode node, XmlNode Parent)
602 if (NodeChanging != null)
603 NodeChanging (node, new XmlNodeChangedEventArgs
604 (XmlNodeChangedAction.Change,
605 node, Parent, Parent));
608 internal void onNodeInserted (XmlNode node, XmlNode newParent)
610 if (NodeInserted != null)
611 NodeInserted (node, new XmlNodeChangedEventArgs
612 (XmlNodeChangedAction.Insert,
613 node, null, newParent));
616 internal void onNodeInserting (XmlNode node, XmlNode newParent)
618 if (NodeInserting != null)
619 NodeInserting (node, new XmlNodeChangedEventArgs
620 (XmlNodeChangedAction.Insert,
621 node, null, newParent));
624 internal void onNodeRemoved (XmlNode node, XmlNode oldParent)
626 if (NodeRemoved != null)
627 NodeRemoved (node, new XmlNodeChangedEventArgs
628 (XmlNodeChangedAction.Remove,
629 node, oldParent, null));
632 internal void onNodeRemoving (XmlNode node, XmlNode oldParent)
634 if (NodeRemoving != null)
635 NodeRemoving (node, new XmlNodeChangedEventArgs
636 (XmlNodeChangedAction.Remove,
637 node, oldParent, null));
640 private void ParseName (string name, out string prefix, out string localName)
642 int indexOfColon = name.IndexOf (':');
644 if (indexOfColon != -1) {
645 prefix = name.Substring (0, indexOfColon);
646 localName = name.Substring (indexOfColon + 1);
653 // Checks that Element's name is valid
654 private void CheckName (String name)
656 // TODO: others validations?
657 if (name.IndexOf (" ") >= 0)
658 throw new XmlException ("The ' ' characted cannot be included in a name");
661 // Reads XmlReader and creates Attribute Node.
662 private XmlAttribute ReadAttributeNode(XmlReader reader)
664 if(reader.NodeType == XmlNodeType.Element)
665 reader.MoveToFirstAttribute ();
666 else if(reader.NodeType != XmlNodeType.Attribute)
667 throw new InvalidOperationException ("bad position to read attribute.");
668 XmlAttribute attribute = CreateAttribute (reader.Prefix, reader.LocalName, reader.NamespaceURI);
669 ReadAttributeNodeValue (reader, attribute);
673 // Reads attribute from XmlReader and then creates attribute value children. XmlAttribute also uses this.
674 internal void ReadAttributeNodeValue(XmlReader reader, XmlAttribute attribute)
676 while(reader.ReadAttributeValue ()) {
677 if(reader.NodeType == XmlNodeType.EntityReference)
678 // FIXME: if DocumentType is available, then try to resolve it.
679 attribute.AppendChild (CreateEntityReference (reader.Name));
680 // FIXME: else if(NodeType == EndEntity) -- reset BaseURI and so on -- ;
682 // (IMHO) Children of Attribute is likely restricted to Text and EntityReference.
683 attribute.AppendChild (CreateTextNode (reader.Value));
687 [MonoTODO ("Child of entity is not simple Value string;Get prefix of NotationDecl")]
688 public virtual XmlNode ReadNode(XmlReader reader)
690 XmlNode resultNode = null;
691 XmlNode newNode = null;
692 XmlNode currentNode = null;
694 if (reader.ReadState == ReadState.Initial)
697 int startDepth = reader.Depth;
698 bool ignoredWhitespace;
699 bool reachedEOF = false;
702 ignoredWhitespace = false;
703 if (reader.NodeType == XmlNodeType.None)
705 throw new Exception ("XML Reader reached to end while reading node.");
708 switch (reader.NodeType) {
710 case XmlNodeType.Attribute:
711 newNode = ReadAttributeNode (reader);
714 case XmlNodeType.CDATA:
715 newNode = CreateCDataSection (reader.Value);
716 if(currentNode != null)
717 currentNode.AppendChild (newNode);
720 case XmlNodeType.Comment:
721 newNode = CreateComment (reader.Value);
722 if(currentNode != null)
723 currentNode.AppendChild (newNode);
726 case XmlNodeType.Element:
727 XmlElement element = CreateElement (reader.Prefix, reader.LocalName, reader.NamespaceURI);
728 element.IsEmpty = reader.IsEmptyElement;
729 if(currentNode != null)
730 currentNode.AppendChild (element);
732 resultNode = element;
734 // set the element's attributes.
735 while (reader.MoveToNextAttribute ()) {
736 element.SetAttributeNode (ReadAttributeNode (reader));
739 reader.MoveToElement ();
741 if (!reader.IsEmptyElement)
742 currentNode = element;
746 case XmlNodeType.EndElement:
747 if(currentNode == null || currentNode.Name != reader.Name)
748 throw new XmlException ("mismatch end tag.");
749 currentNode = currentNode.ParentNode;
752 case XmlNodeType.EndEntity:
753 break; // no operation
755 case XmlNodeType.ProcessingInstruction:
756 newNode = CreateProcessingInstruction (reader.Name, reader.Value);
757 if(currentNode != null)
758 currentNode.AppendChild (newNode);
761 case XmlNodeType.Text:
762 newNode = CreateTextNode (reader.Value);
763 if(currentNode != null)
764 currentNode.AppendChild (newNode);
767 case XmlNodeType.XmlDeclaration:
768 // empty strings are dummy, then gives over setting value contents to setter.
769 newNode = CreateXmlDeclaration ("1.0" , String.Empty, String.Empty);
770 ((XmlDeclaration)newNode).Value = reader.Value;
771 if(currentNode != null)
772 throw new XmlException ("XmlDeclaration at invalid position.");
775 case XmlNodeType.DocumentType:
777 XmlTextReader xtReader = reader as XmlTextReader;
778 if(xtReader == null) {
779 xtReader = new XmlTextReader (reader.ReadOuterXml (),
780 XmlNodeType.DocumentType,
781 new XmlParserContext (NameTable, ConstructNamespaceManager(), XmlLang, XmlSpace));
784 newNode = ReadDoctypeNode (xtReader);
785 if(currentNode != null)
786 throw new XmlException ("XmlDocumentType at invalid position.");
789 case XmlNodeType.EntityReference:
790 newNode = CreateEntityReference (reader.Name);
791 if(currentNode != null)
792 currentNode.AppendChild (newNode);
795 case XmlNodeType.SignificantWhitespace:
796 newNode = CreateSignificantWhitespace (reader.Value);
797 if(currentNode != null)
798 currentNode.AppendChild (newNode);
801 case XmlNodeType.Whitespace:
802 if(PreserveWhitespace) {
803 newNode = CreateWhitespace (reader.Value);
804 if(currentNode != null)
805 currentNode.AppendChild (newNode);
808 ignoredWhitespace = true;
812 } while (ignoredWhitespace || reader.Depth > startDepth ||
813 (reader.Depth == startDepth && reader.NodeType == XmlNodeType.EndElement));
814 return resultNode != null ? resultNode : newNode;
817 private XmlDocumentType ReadDoctypeNode (XmlTextReader xtReader)
819 XmlDocumentType doctype = CreateDocumentType (xtReader.Name,
820 xtReader.GetAttribute ("PUBLIC"),
821 xtReader.GetAttribute ("SYSTEM"),
823 DTDObjectModel subset = xtReader.currentSubset;
824 foreach (DTDEntityDeclaration decl in subset.EntityDecls.Values) {
825 XmlNode n = new XmlEntity (decl.Name, decl.NotationName,
826 decl.PublicId, decl.SystemId, this);
827 // FIXME: Value is more complex, similar to Attribute.
828 n.insertBeforeIntern (this.CreateTextNode (decl.EntityValue), null);
829 doctype.entities.Nodes.Add (n);
831 foreach (DTDNotationDeclaration decl in subset.NotationDecls.Values) {
832 XmlNode n = new XmlNotation (decl.LocalName, decl.Prefix,
833 decl.PublicId, decl.SystemId, this);
834 doctype.notations.Nodes.Add (n);
836 foreach (DTDElementDeclaration decl in subset.ElementDecls.Values) {
837 doctype.elementDecls.Add (decl.Name, decl.Clone ());
839 foreach (DTDAttListDeclaration decl in subset.AttListDecls.Values) {
840 doctype.attListDecls.Add (decl.Name, decl.Clone ());
845 public virtual void Save(Stream outStream)
847 XmlTextWriter xmlWriter = new XmlTextWriter (outStream, Encoding.UTF8);
848 xmlWriter.Formatting = Formatting.Indented;
849 WriteContentTo (xmlWriter);
853 public virtual void Save (string filename)
855 XmlTextWriter xmlWriter = new XmlTextWriter (filename, Encoding.UTF8);
856 xmlWriter.Formatting = Formatting.Indented;
857 WriteContentTo (xmlWriter);
862 public virtual void Save (TextWriter writer)
864 XmlTextWriter xmlWriter = new XmlTextWriter (writer);
865 xmlWriter.Formatting = Formatting.Indented;
866 WriteContentTo (xmlWriter);
870 public virtual void Save (XmlWriter xmlWriter)
873 // This should preserve white space if PreserveWhiteSpace is true
875 WriteContentTo (xmlWriter);
879 public override void WriteContentTo (XmlWriter w)
881 foreach(XmlNode childNode in ChildNodes) {
882 childNode.WriteTo (w);
886 public override void WriteTo (XmlWriter w)
891 private void AddDefaultNameTableKeys ()
893 // The following keys are default of MS .NET Framework
894 nameTable.Add ("#text");
895 nameTable.Add ("xml");
896 nameTable.Add ("xmlns");
897 nameTable.Add ("#entity");
898 nameTable.Add ("#document-fragment");
899 nameTable.Add ("#comment");
900 nameTable.Add ("space");
901 nameTable.Add ("id");
902 nameTable.Add ("#whitespace");
903 nameTable.Add ("http://www.w3.org/2000/xmlns/");
904 nameTable.Add ("#cdata-section");
905 nameTable.Add ("lang");
906 nameTable.Add ("#document");
907 nameTable.Add ("#significant-whitespace");