XmlProcessingInstruction.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // System.Xml.XmlProcessingInstruction
  3. //
  4. // Author:
  5. // Kral Ferch <[email protected]>
  6. //
  7. // (C) 2002 Kral Ferch
  8. //
  9. using System;
  10. using System.Xml.XPath;
  11. namespace System.Xml
  12. {
  13. public class XmlProcessingInstruction : XmlLinkedNode
  14. {
  15. string target;
  16. string data;
  17. #region Constructors
  18. protected internal XmlProcessingInstruction (string target, string data, XmlDocument doc) : base(doc)
  19. {
  20. if (data == null)
  21. data = String.Empty;
  22. this.target = target;
  23. this.data = data;
  24. }
  25. #endregion
  26. #region Properties
  27. public string Data
  28. {
  29. get { return data; }
  30. set { data = value; }
  31. }
  32. public override string InnerText
  33. {
  34. get { return Data; }
  35. set { data = value; }
  36. }
  37. public override string LocalName
  38. {
  39. get { return target; }
  40. }
  41. public override string Name
  42. {
  43. get { return target; }
  44. }
  45. public override XmlNodeType NodeType
  46. {
  47. get { return XmlNodeType.ProcessingInstruction; }
  48. }
  49. internal override XPathNodeType XPathNodeType {
  50. get {
  51. return XPathNodeType.ProcessingInstruction;
  52. }
  53. }
  54. public string Target
  55. {
  56. get { return target; }
  57. }
  58. public override string Value
  59. {
  60. get { return data; }
  61. set {
  62. if (this.IsReadOnly)
  63. throw new ArgumentException ("This node is read-only.");
  64. else
  65. data = value;
  66. }
  67. }
  68. #endregion
  69. #region Methods
  70. public override XmlNode CloneNode (bool deep)
  71. {
  72. return new XmlProcessingInstruction (target, data, OwnerDocument);
  73. }
  74. public override void WriteContentTo (XmlWriter w) { }
  75. public override void WriteTo (XmlWriter w)
  76. {
  77. w.WriteProcessingInstruction (target, data);
  78. }
  79. #endregion
  80. }
  81. }