XmlDocument.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. //
  2. // System.Xml.XmlDocument
  3. //
  4. // Authors:
  5. // Daniel Weber ([email protected])
  6. // Kral Ferch <[email protected]>
  7. // Jason Diamond <[email protected]>
  8. // Miguel de Icaza ([email protected])
  9. // Duncan Mak ([email protected])
  10. //
  11. // (C) 2001 Daniel Weber
  12. // (C) 2002 Kral Ferch, Jason Diamond, Miguel de Icaza, Duncan Mak
  13. //
  14. using System;
  15. using System.IO;
  16. using System.Text;
  17. using System.Xml.XPath;
  18. using System.Diagnostics;
  19. using System.Collections;
  20. namespace System.Xml
  21. {
  22. public class XmlDocument : XmlNode
  23. {
  24. #region Fields
  25. XmlLinkedNode lastLinkedChild;
  26. XmlNameTable nameTable;
  27. string baseURI = String.Empty;
  28. #endregion
  29. #region Constructors
  30. public XmlDocument () : base (null)
  31. {
  32. System.Xml.NameTable nt = new NameTable();
  33. // keys below are default of MS .NET Framework
  34. nt.Add("#text");
  35. nt.Add("xml");
  36. nt.Add("xmlns");
  37. nt.Add("#entity");
  38. nt.Add("#document-fragment");
  39. nt.Add("#comment");
  40. nt.Add("space");
  41. nt.Add("id");
  42. nt.Add("#whitespace");
  43. nt.Add("http://www.w3.org/2000/xmlns/");
  44. nt.Add("#cdata-section");
  45. nt.Add("lang");
  46. nameTable = nt;
  47. }
  48. [MonoTODO]
  49. protected internal XmlDocument (XmlImplementation imp) : base (null)
  50. {
  51. throw new NotImplementedException ();
  52. }
  53. public XmlDocument (XmlNameTable nt) : base (null)
  54. {
  55. nameTable = nt;
  56. }
  57. #endregion
  58. #region Events
  59. public event XmlNodeChangedEventHandler NodeChanged;
  60. public event XmlNodeChangedEventHandler NodeChanging;
  61. public event XmlNodeChangedEventHandler NodeInserted;
  62. public event XmlNodeChangedEventHandler NodeInserting;
  63. public event XmlNodeChangedEventHandler NodeRemoved;
  64. public event XmlNodeChangedEventHandler NodeRemoving;
  65. #endregion
  66. #region Properties
  67. public override string BaseURI {
  68. get {
  69. return baseURI;
  70. }
  71. }
  72. public XmlElement DocumentElement {
  73. get {
  74. XmlNode node = FirstChild;
  75. while (node != null) {
  76. if (node is XmlElement)
  77. break;
  78. node = node.NextSibling;
  79. }
  80. return node != null ? node as XmlElement : null;
  81. }
  82. }
  83. [MonoTODO]
  84. public virtual XmlDocumentType DocumentType {
  85. get { throw new NotImplementedException(); }
  86. }
  87. [MonoTODO]
  88. public XmlImplementation Implementation {
  89. get { throw new NotImplementedException(); }
  90. }
  91. [MonoTODO ("Setter.")]
  92. public override string InnerXml {
  93. get {
  94. // Not sure why this is an override. Passing through for now.
  95. return base.InnerXml;
  96. }
  97. set { throw new NotImplementedException(); }
  98. }
  99. public override bool IsReadOnly {
  100. get { return false; }
  101. }
  102. internal override XmlLinkedNode LastLinkedChild {
  103. get {
  104. return lastLinkedChild;
  105. }
  106. set {
  107. lastLinkedChild = value;
  108. }
  109. }
  110. public override string LocalName {
  111. get { return "#document"; }
  112. }
  113. public override string Name {
  114. get { return "#document"; }
  115. }
  116. public XmlNameTable NameTable {
  117. get { return nameTable; }
  118. }
  119. public override XmlNodeType NodeType {
  120. get { return XmlNodeType.Document; }
  121. }
  122. public override XmlDocument OwnerDocument {
  123. get { return null; }
  124. }
  125. [MonoTODO]
  126. public bool PreserveWhitespace {
  127. get { throw new NotImplementedException(); }
  128. set { throw new NotImplementedException(); }
  129. }
  130. [MonoTODO]
  131. public virtual XmlResolver XmlResolver {
  132. set { throw new NotImplementedException(); }
  133. }
  134. #endregion
  135. #region Methods
  136. [MonoTODO]
  137. public override XmlNode CloneNode (bool deep)
  138. {
  139. throw new NotImplementedException ();
  140. }
  141. public XmlAttribute CreateAttribute (string name)
  142. {
  143. return CreateAttribute (name, String.Empty);
  144. }
  145. public XmlAttribute CreateAttribute (string qualifiedName, string namespaceURI)
  146. {
  147. string prefix;
  148. string localName;
  149. ParseName (qualifiedName, out prefix, out localName);
  150. return CreateAttribute (prefix, localName, namespaceURI);
  151. }
  152. public virtual XmlAttribute CreateAttribute (string prefix, string localName, string namespaceURI)
  153. {
  154. if ((localName == null) || (localName == String.Empty))
  155. throw new ArgumentException ("The attribute local name cannot be empty.");
  156. return new XmlAttribute (prefix, localName, namespaceURI, this);
  157. }
  158. public virtual XmlCDataSection CreateCDataSection (string data)
  159. {
  160. return new XmlCDataSection (data, this);
  161. }
  162. public virtual XmlComment CreateComment (string data)
  163. {
  164. return new XmlComment(data, this);
  165. }
  166. [MonoTODO]
  167. protected internal virtual XmlAttribute CreateDefaultAttribute (string prefix, string localName, string namespaceURI)
  168. {
  169. throw new NotImplementedException ();
  170. }
  171. [MonoTODO]
  172. public virtual XmlDocumentFragment CreateDocumentFragment ()
  173. {
  174. throw new NotImplementedException ();
  175. }
  176. public virtual XmlDocumentType CreateDocumentType (string name, string publicId,
  177. string systemId, string internalSubset)
  178. {
  179. return new XmlDocumentType (name, publicId, systemId, internalSubset, this);
  180. }
  181. public XmlElement CreateElement (string name)
  182. {
  183. return CreateElement (name, String.Empty);
  184. }
  185. public XmlElement CreateElement (
  186. string qualifiedName,
  187. string namespaceURI)
  188. {
  189. string prefix;
  190. string localName;
  191. ParseName (qualifiedName, out prefix, out localName);
  192. return CreateElement (prefix, localName, namespaceURI);
  193. }
  194. public virtual XmlElement CreateElement (
  195. string prefix,
  196. string localName,
  197. string namespaceURI)
  198. {
  199. if ((localName == null) || (localName == String.Empty))
  200. throw new ArgumentException ("The local name for elements or attributes cannot be null or an empty string.");
  201. return new XmlElement (prefix != null ? prefix : String.Empty, localName, namespaceURI != null ? namespaceURI : String.Empty, this);
  202. }
  203. [MonoTODO]
  204. public virtual XmlEntityReference CreateEntityReference (string name)
  205. {
  206. throw new NotImplementedException ();
  207. }
  208. [MonoTODO]
  209. protected internal virtual XPathNavigator CreateNavigator (XmlNode node)
  210. {
  211. throw new NotImplementedException ();
  212. }
  213. public virtual XmlNode CreateNode (
  214. string nodeTypeString,
  215. string name,
  216. string namespaceURI)
  217. {
  218. return CreateNode (GetNodeTypeFromString (nodeTypeString), name, namespaceURI);
  219. }
  220. public virtual XmlNode CreateNode (
  221. XmlNodeType type,
  222. string name,
  223. string namespaceURI)
  224. {
  225. string prefix = null;
  226. string localName = name;
  227. if ((type == XmlNodeType.Attribute) || (type == XmlNodeType.Element) || (type == XmlNodeType.EntityReference))
  228. ParseName (name, out prefix, out localName);
  229. return CreateNode (type, prefix, localName, namespaceURI);
  230. }
  231. public virtual XmlNode CreateNode (
  232. XmlNodeType type,
  233. string prefix,
  234. string name,
  235. string namespaceURI)
  236. {
  237. switch (type) {
  238. case XmlNodeType.Attribute: return CreateAttribute (prefix, name, namespaceURI);
  239. case XmlNodeType.CDATA: return CreateCDataSection (null);
  240. case XmlNodeType.Comment: return CreateComment (null);
  241. case XmlNodeType.Document: return new XmlDocument (); // TODO - test to see which constructor to use, i.e. use existing NameTable or not.
  242. case XmlNodeType.DocumentFragment: return CreateDocumentFragment ();
  243. case XmlNodeType.DocumentType: return CreateDocumentType (null, null, null, null);
  244. case XmlNodeType.Element: return CreateElement (prefix, name, namespaceURI);
  245. case XmlNodeType.EntityReference: return CreateEntityReference (null);
  246. case XmlNodeType.ProcessingInstruction: return CreateProcessingInstruction (null, null);
  247. case XmlNodeType.SignificantWhitespace: return CreateSignificantWhitespace (String.Empty);
  248. case XmlNodeType.Text: return CreateTextNode (null);
  249. case XmlNodeType.Whitespace: return CreateWhitespace (String.Empty);
  250. case XmlNodeType.XmlDeclaration: return CreateXmlDeclaration ("1.0", null, null);
  251. default: throw new ArgumentOutOfRangeException(String.Format("{0}\nParameter name: {1}",
  252. "Specified argument was out of the range of valid values", type.ToString ()));
  253. }
  254. }
  255. public virtual XmlProcessingInstruction CreateProcessingInstruction (
  256. string target,
  257. string data)
  258. {
  259. return new XmlProcessingInstruction (target, data, this);
  260. }
  261. public virtual XmlSignificantWhitespace CreateSignificantWhitespace (string text)
  262. {
  263. foreach (char c in text)
  264. if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
  265. throw new ArgumentException ("Invalid whitespace characters.");
  266. return new XmlSignificantWhitespace (text, this);
  267. }
  268. public virtual XmlText CreateTextNode (string text)
  269. {
  270. return new XmlText (text, this);
  271. }
  272. public virtual XmlWhitespace CreateWhitespace (string text)
  273. {
  274. foreach (char c in text)
  275. if ((c != ' ') && (c != '\r') && (c != '\n') && (c != '\t'))
  276. throw new ArgumentException ("Invalid whitespace characters.");
  277. return new XmlWhitespace (text, this);
  278. }
  279. public virtual XmlDeclaration CreateXmlDeclaration (string version, string encoding,
  280. string standalone)
  281. {
  282. if (version != "1.0")
  283. throw new ArgumentException ("version string is not correct.");
  284. if ((standalone != null) && !((standalone == "yes") || (standalone == "no")))
  285. throw new ArgumentException ("standalone string is not correct.");
  286. return new XmlDeclaration (version, encoding, standalone, this);
  287. }
  288. [MonoTODO]
  289. public virtual XmlElement GetElementById (string elementId)
  290. {
  291. throw new NotImplementedException ();
  292. }
  293. public virtual XmlNodeList GetElementsByTagName (string name)
  294. {
  295. ArrayList nodeArrayList = new ArrayList ();
  296. this.searchNodesRecursively (this, name, nodeArrayList);
  297. return new XmlNodeArrayList (nodeArrayList);
  298. }
  299. private void searchNodesRecursively (XmlNode argNode, string argName,
  300. ArrayList argArrayList)
  301. {
  302. XmlNodeList xmlNodeList = argNode.ChildNodes;
  303. foreach (XmlNode node in xmlNodeList){
  304. if (node.Name.Equals (argName))
  305. argArrayList.Add (node);
  306. else
  307. this.searchNodesRecursively (node, argName, argArrayList);
  308. }
  309. }
  310. private void searchNodesRecursively (XmlNode argNode, string argName, string argNamespaceURI,
  311. ArrayList argArrayList)
  312. {
  313. XmlNodeList xmlNodeList = argNode.ChildNodes;
  314. foreach (XmlNode node in xmlNodeList){
  315. if (node.LocalName.Equals (argName) && node.NamespaceURI.Equals (argNamespaceURI))
  316. argArrayList.Add (node);
  317. else
  318. this.searchNodesRecursively (node, argName, argNamespaceURI, argArrayList);
  319. }
  320. }
  321. public virtual XmlNodeList GetElementsByTagName (string localName, string namespaceURI)
  322. {
  323. ArrayList nodeArrayList = new ArrayList ();
  324. this.searchNodesRecursively (this, localName, namespaceURI, nodeArrayList);
  325. return new XmlNodeArrayList (nodeArrayList);
  326. }
  327. private XmlNodeType GetNodeTypeFromString (string nodeTypeString)
  328. {
  329. switch (nodeTypeString) {
  330. case "attribute": return XmlNodeType.Attribute;
  331. case "cdatasection": return XmlNodeType.CDATA;
  332. case "comment": return XmlNodeType.Comment;
  333. case "document": return XmlNodeType.Document;
  334. case "documentfragment": return XmlNodeType.DocumentFragment;
  335. case "documenttype": return XmlNodeType.DocumentType;
  336. case "element": return XmlNodeType.Element;
  337. case "entityreference": return XmlNodeType.EntityReference;
  338. case "processinginstruction": return XmlNodeType.ProcessingInstruction;
  339. case "significantwhitespace": return XmlNodeType.SignificantWhitespace;
  340. case "text": return XmlNodeType.Text;
  341. case "whitespace": return XmlNodeType.Whitespace;
  342. default:
  343. throw new ArgumentException(String.Format("The string doesn't represent any node type : {0}.", nodeTypeString));
  344. }
  345. }
  346. [MonoTODO]
  347. public virtual XmlNode ImportNode (XmlNode node, bool deep)
  348. {
  349. // How to resolve default attribute values?
  350. switch(node.NodeType)
  351. {
  352. case XmlNodeType.Attribute:
  353. {
  354. XmlAttribute src_att = node as XmlAttribute;
  355. XmlAttribute dst_att = this.CreateAttribute(src_att.Prefix, src_att.LocalName, src_att.NamespaceURI);
  356. // TODO: resolve default attribute values
  357. dst_att.Value = src_att.Value;
  358. return dst_att;
  359. }
  360. case XmlNodeType.CDATA:
  361. return this.CreateCDataSection(node.Value);
  362. case XmlNodeType.Comment:
  363. return this.CreateComment(node.Value);
  364. case XmlNodeType.Document:
  365. throw new XmlException("Document cannot be imported.");
  366. case XmlNodeType.DocumentFragment:
  367. {
  368. XmlDocumentFragment df = this.CreateDocumentFragment();
  369. if(deep)
  370. {
  371. foreach(XmlNode n in node.ChildNodes)
  372. {
  373. df.AppendChild(this.ImportNode(n, deep));
  374. }
  375. }
  376. return df;
  377. }
  378. case XmlNodeType.DocumentType:
  379. throw new XmlException("DocumentType cannot be imported.");
  380. case XmlNodeType.Element:
  381. {
  382. XmlElement src = (XmlElement)node;
  383. XmlElement dst = this.CreateElement(src.Prefix, src.LocalName, src.NamespaceURI);
  384. foreach(XmlAttribute attr in src.Attributes)
  385. {
  386. // TODO: create default attribute values
  387. dst.SetAttributeNode((XmlAttribute)this.ImportNode(attr, deep));
  388. }
  389. if(deep)
  390. {
  391. foreach(XmlNode n in src.ChildNodes)
  392. dst.AppendChild(this.ImportNode(n, deep));
  393. }
  394. return dst;
  395. }
  396. case XmlNodeType.EndElement:
  397. throw new XmlException ("Illegal ImportNode call for NodeType.EndElement");
  398. case XmlNodeType.EndEntity:
  399. throw new XmlException ("Illegal ImportNode call for NodeType.EndEntity");
  400. case XmlNodeType.Entity:
  401. throw new NotImplementedException ();
  402. // [2002.10.14] CreateEntityReference not implemented.
  403. case XmlNodeType.EntityReference:
  404. throw new NotImplementedException("ImportNode of EntityReference not implemented mainly because CreateEntityReference was implemented in the meantime.");
  405. // return this.CreateEntityReference(node.Name);
  406. case XmlNodeType.None:
  407. throw new XmlException ("Illegal ImportNode call for NodeType.None");
  408. case XmlNodeType.Notation:
  409. throw new NotImplementedException ();
  410. case XmlNodeType.ProcessingInstruction:
  411. XmlProcessingInstruction pi = node as XmlProcessingInstruction;
  412. return this.CreateProcessingInstruction(pi.Target, pi.Data);
  413. case XmlNodeType.SignificantWhitespace:
  414. return this.CreateSignificantWhitespace(node.Value);
  415. case XmlNodeType.Text:
  416. return this.CreateTextNode(node.Value);
  417. case XmlNodeType.Whitespace:
  418. return this.CreateWhitespace(node.Value);
  419. // I don't know how to test it...
  420. case XmlNodeType.XmlDeclaration:
  421. // return this.CreateNode(XmlNodeType.XmlDeclaration, String.Empty, node.Value);
  422. throw new NotImplementedException ();
  423. default:
  424. throw new NotImplementedException ();
  425. }
  426. }
  427. public virtual void Load (Stream inStream)
  428. {
  429. XmlReader xmlReader = new XmlTextReader (inStream);
  430. Load (xmlReader);
  431. }
  432. public virtual void Load (string filename)
  433. {
  434. baseURI = filename;
  435. XmlReader xmlReader = new XmlTextReader (new StreamReader (filename));
  436. Load (xmlReader);
  437. }
  438. public virtual void Load (TextReader txtReader)
  439. {
  440. Load (new XmlTextReader (txtReader));
  441. }
  442. public virtual void Load (XmlReader xmlReader)
  443. {
  444. // Reset our document
  445. // For now this just means removing all our children but later this
  446. // may turn out o need to call a private method that resets other things
  447. // like properties we have, etc.
  448. RemoveAll ();
  449. XmlNode currentNode = this;
  450. XmlNode newNode;
  451. #if true
  452. this.ConstructDOM(xmlReader, currentNode);
  453. #else
  454. // Below are copied to XmlNode.Construct(currentNode, xmlReader)
  455. while (xmlReader.Read ())
  456. {
  457. switch (xmlReader.NodeType) {
  458. case XmlNodeType.CDATA:
  459. newNode = CreateCDataSection(xmlReader.Value);
  460. currentNode.AppendChild (newNode);
  461. break;
  462. case XmlNodeType.Comment:
  463. newNode = CreateComment (xmlReader.Value);
  464. currentNode.AppendChild (newNode);
  465. break;
  466. case XmlNodeType.Element:
  467. XmlElement element = CreateElement (xmlReader.Prefix, xmlReader.LocalName, xmlReader.NamespaceURI);
  468. currentNode.AppendChild (element);
  469. // set the element's attributes.
  470. while (xmlReader.MoveToNextAttribute ()) {
  471. XmlAttribute attribute = CreateAttribute (xmlReader.Prefix, xmlReader.LocalName, xmlReader.NamespaceURI);
  472. attribute.Value = xmlReader.Value;
  473. element.SetAttributeNode (attribute);
  474. }
  475. xmlReader.MoveToElement ();
  476. // if this element isn't empty, push it onto our "stack".
  477. if (!xmlReader.IsEmptyElement)
  478. currentNode = element;
  479. break;
  480. case XmlNodeType.EndElement:
  481. currentNode = currentNode.ParentNode;
  482. break;
  483. case XmlNodeType.ProcessingInstruction:
  484. newNode = CreateProcessingInstruction (xmlReader.Name, xmlReader.Value);
  485. currentNode.AppendChild (newNode);
  486. break;
  487. case XmlNodeType.Text:
  488. newNode = CreateTextNode (xmlReader.Value);
  489. currentNode.AppendChild (newNode);
  490. break;
  491. }
  492. }
  493. #endif
  494. }
  495. public virtual void LoadXml (string xml)
  496. {
  497. XmlReader xmlReader = new XmlTextReader (new StringReader (xml));
  498. Load (xmlReader);
  499. }
  500. internal void onNodeChanged (XmlNode node, XmlNode Parent)
  501. {
  502. if (NodeChanged != null)
  503. NodeChanged (node, new XmlNodeChangedEventArgs
  504. (XmlNodeChangedAction.Change,
  505. node, Parent, Parent));
  506. }
  507. internal void onNodeChanging(XmlNode node, XmlNode Parent)
  508. {
  509. if (NodeChanging != null)
  510. NodeChanging (node, new XmlNodeChangedEventArgs
  511. (XmlNodeChangedAction.Change,
  512. node, Parent, Parent));
  513. }
  514. internal void onNodeInserted (XmlNode node, XmlNode newParent)
  515. {
  516. if (NodeInserted != null)
  517. NodeInserted (node, new XmlNodeChangedEventArgs
  518. (XmlNodeChangedAction.Insert,
  519. node, null, newParent));
  520. }
  521. internal void onNodeInserting (XmlNode node, XmlNode newParent)
  522. {
  523. if (NodeInserting != null)
  524. NodeInserting (node, new XmlNodeChangedEventArgs
  525. (XmlNodeChangedAction.Insert,
  526. node, null, newParent));
  527. }
  528. internal void onNodeRemoved (XmlNode node, XmlNode oldParent)
  529. {
  530. if (NodeRemoved != null)
  531. NodeRemoved (node, new XmlNodeChangedEventArgs
  532. (XmlNodeChangedAction.Remove,
  533. node, oldParent, null));
  534. }
  535. internal void onNodeRemoving (XmlNode node, XmlNode oldParent)
  536. {
  537. if (NodeRemoving != null)
  538. NodeRemoving (node, new XmlNodeChangedEventArgs
  539. (XmlNodeChangedAction.Remove,
  540. node, oldParent, null));
  541. }
  542. private void ParseName (string name, out string prefix, out string localName)
  543. {
  544. int indexOfColon = name.IndexOf (':');
  545. if (indexOfColon != -1) {
  546. prefix = name.Substring (0, indexOfColon);
  547. localName = name.Substring (indexOfColon + 1);
  548. } else {
  549. prefix = "";
  550. localName = name;
  551. }
  552. }
  553. [MonoTODO]
  554. public virtual XmlNode ReadNode(XmlReader reader)
  555. {
  556. throw new NotImplementedException ();
  557. }
  558. [MonoTODO ("Verify what encoding is used by default; Should use PreserveWhiteSpace")]
  559. public virtual void Save(Stream outStream)
  560. {
  561. XmlTextWriter xmlWriter = new XmlTextWriter (outStream, Encoding.UTF8);
  562. WriteContentTo (xmlWriter);
  563. xmlWriter.Close ();
  564. }
  565. [MonoTODO ("Verify what encoding is used by default; Should use PreseveWhiteSpace")]
  566. public virtual void Save (string filename)
  567. {
  568. XmlTextWriter xmlWriter = new XmlTextWriter (filename, Encoding.UTF8);
  569. WriteContentTo (xmlWriter);
  570. xmlWriter.Close ();
  571. }
  572. [MonoTODO]
  573. public virtual void Save (TextWriter writer)
  574. {
  575. XmlTextWriter xmlWriter = new XmlTextWriter (writer);
  576. WriteContentTo (xmlWriter);
  577. xmlWriter.Flush ();
  578. }
  579. [MonoTODO ("Should preserve white space if PreserveWhisspace is set")]
  580. public virtual void Save (XmlWriter xmlWriter)
  581. {
  582. //
  583. // This should preserve white space if PreserveWhiteSpace is true
  584. //
  585. WriteContentTo (xmlWriter);
  586. xmlWriter.Flush ();
  587. }
  588. public override void WriteContentTo (XmlWriter w)
  589. {
  590. foreach(XmlNode childNode in ChildNodes)
  591. childNode.WriteTo(w);
  592. }
  593. public override void WriteTo (XmlWriter w)
  594. {
  595. WriteContentTo(w);
  596. }
  597. #endregion
  598. }
  599. }