-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebKitDOMCoreClasses.cs
More file actions
1559 lines (1374 loc) · 47.9 KB
/
WebKitDOMCoreClasses.cs
File metadata and controls
1559 lines (1374 loc) · 47.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2009, Peter Nelson (charn.opcode@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using WebKit.Interop;
namespace WebKit.DOM
{
public enum NodeType
{
Element = 1,
Attribute = 2,
Text = 3,
CDATASection = 4,
EntityReference = 5,
Entity = 6,
ProcessingInstruction = 7,
Comment = 8,
Document = 9,
DocumentType = 10,
DocumentFragment = 11,
Notation = 12,
XPathNamespace = 13
}
/// <summary>
/// Represents an unordered list of DOM Nodes where elements are accessed by name.
/// </summary>
public class NamedNodeMap : IEnumerable<Node>
{
private IDOMNamedNodeMap namedNodeMap;
/// <summary>
/// NamedNodeMap constructor.
/// </summary>
/// <param name="NamedNodeMap">WebKit IDOMNamedNodeMap object.</param>
protected NamedNodeMap(IDOMNamedNodeMap NamedNodeMap)
{
this.namedNodeMap = NamedNodeMap;
}
internal static NamedNodeMap Create(IDOMNamedNodeMap NamedNodeMap)
{
return new NamedNodeMap(NamedNodeMap);
}
#region NamedNodeMap Object Properties
/// <summary>
/// Gets the number of nodes in the collection.
/// </summary>
public int Length
{
get
{
return (int)namedNodeMap.length();
}
}
#endregion
#region Indexers
/// <summary>
/// Gets the item at the specified index.
/// </summary>
/// <param name="index">Index of the item to get.</param>
/// <returns>Node at the specified index.</returns>
public Node this[int index]
{
get
{
if (index < 0 || index >= (int)namedNodeMap.length())
return null;
return Node.Create(namedNodeMap.item((uint)index));
}
}
/// <summary>
/// Gets the item with the specified name.
/// </summary>
/// <param name="name">Name of the item to get.</param>
/// <returns>Node with the specified name.</returns>
public Node this[string name]
{
get
{
return Node.Create(namedNodeMap.getNamedItem(name));
}
}
/// <summary>
/// Gets the item with the specified namespace and name.
/// </summary>
/// <param name="NSURI">Namespace of the item to get.</param>
/// <param name="localName">Name of the item to get.</param>
/// <returns>Node with the specified namespace and name.</returns>
public Node this[string NSURI, string localName]
{
get
{
return Node.Create(namedNodeMap.getNamedItemNS(NSURI, localName));
}
}
#endregion
#region NamedNodeMap Object Methods
/// <summary>
/// Gets the item with the specified name.
/// </summary>
/// <param name="Name">Name of the item to get.</param>
/// <returns>Node with the specified name.</returns>
public Node GetNamedItem(string Name)
{
return this[Name];
}
/// <summary>
/// Gets the item with the specified namespace and name.
/// </summary>
/// <param name="NamespaceURI">Namespace of the item to get.</param>
/// <param name="LocalName">Name of the item to get.</param>
/// <returns>Node with the specified namespace and name.</returns>
public Node GetNamedItemNS(string NamespaceURI, string LocalName)
{
return this[NamespaceURI, LocalName];
}
/// <summary>
/// Gets the item at the specified index.
/// </summary>
/// <param name="Index">Index of the item to get.</param>
/// <returns>Node at the specified index.</returns>
public Node GetItem(int Index)
{
return this[Index];
}
/// <summary>
/// Removes the item with the specified name from the collection.
/// </summary>
/// <param name="Name">Name of the item to remove.</param>
/// <returns>The removed node.</returns>
public Node RemoveNamedItem(string Name)
{
return Node.Create(namedNodeMap.removeNamedItem(Name));
}
/// <summary>
/// Removes the item with the specified namespace and name from the collection.
/// </summary>
/// <param name="NamespaceURI">Namespace of the item to remove.</param>
/// <param name="LocalName">Name of the item to remove.</param>
/// <returns>The removed node.</returns>
public Node RemoveNamedItemNS(string NamespaceURI, string LocalName)
{
return Node.Create(namedNodeMap.removeNamedItemNS(NamespaceURI, LocalName));
}
/// <summary>
/// Adds the specified node to the collection.
/// </summary>
/// <param name="Node">The node to add.</param>
/// <returns>The added node.</returns>
public Node SetNamedItem(Node Node)
{
return Node.Create(namedNodeMap.setNamedItem((IDOMNode)Node.GetWebKitObject()));
}
/// <summary>
/// Adds the specified node to the collection.
/// </summary>
/// <param name="Node">The node to add.</param>
/// <returns>The added node.</returns>
public Node SetNamedItemNS(Node Node)
{
return Node.Create(namedNodeMap.setNamedItemNS((IDOMNode)Node.GetWebKitObject()));
}
#endregion
#region IEnumerable<Node> Members
/// <summary>
/// Gets an enumerator for the collection.
/// </summary>
/// <returns>An enumerator for the collection.</returns>
public IEnumerator<Node> GetEnumerator()
{
for (uint i = 0; i < namedNodeMap.length(); ++i)
yield return Node.Create(namedNodeMap.item(i));
}
#endregion
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
foreach (Node node in this)
yield return node;
}
#endregion
}
/// <summary>
/// Represents a DOM Node.
/// </summary>
public class Node
{
private IDOMNode node;
/// <summary>
/// Gets the underlying WebKit IDOMNode object.
/// </summary>
/// <returns>WebKit IDOMNode object representing this node.</returns>
public object GetWebKitObject()
{
return node;
}
/// <summary>
/// Node Constructor.
/// </summary>
/// <param name="Node">WebKit IDOMNode object.</param>
protected Node(IDOMNode Node)
{
this.node = Node;
}
internal static Node Create(IDOMNode Node)
{
if (Node is IDOMDocument)
return Document.Create(Node as IDOMDocument);
else if (Node is IDOMAttr)
return Attr.Create(Node as IDOMAttr);
else if (Node is IDOMCharacterData)
return CharacterData.Create(Node as IDOMCharacterData);
else if (Node is IDOMElement)
return Element.Create(Node as IDOMElement);
else if (Node is IDOMDocumentType)
return DocumentType.Create(Node as IDOMDocumentType);
else if (Node is IDOMDocumentFragment)
return DocumentFragment.Create(Node as IDOMDocumentFragment);
else if (Node is IDOMEntityReference)
return EntityReference.Create(Node as IDOMEntityReference);
else if (Node is IDOMProcessingInstruction)
return ProcessingInstruction.Create(Node as IDOMProcessingInstruction);
else
return new Node(Node);
}
#region Node Object Properties
/// <summary>
/// Gets a collection containing this node's children.
/// </summary>
public NodeList ChildNodes
{
get
{
return NodeList.Create(node.childNodes());
}
}
/// <summary>
/// Gets the first child of this node.
/// </summary>
public Node FirstChild
{
get
{
return Node.Create(node.firstChild());
}
}
/// <summary>
/// Gets the last child of this node.
/// </summary>
public Node LastChild
{
get
{
return Node.Create(node.lastChild());
}
}
/// <summary>
/// Gets the local part of the name of a node.
/// </summary>
public string LocalName
{
get
{
return node.localName();
}
}
/// <summary>
/// Gets the namespace URI of this node.
/// </summary>
public Uri NamespaceURI
{
get
{
Uri nsURI;
Uri.TryCreate(node.namespaceURI(), UriKind.RelativeOrAbsolute, out nsURI);
return nsURI;
}
}
/// <summary>
/// Gets the node immediately following this one.
/// </summary>
public Node NextSibling
{
get
{
return Node.Create(node.nextSibling());
}
}
/// <summary>
/// Gets the name of this node.
/// </summary>
public string NodeName
{
get
{
return node.nodeName();
}
}
/// <summary>
/// Gets the type of this node.
/// </summary>
public NodeType NodeType
{
get
{
return (NodeType)node.nodeType();
}
}
/// <summary>
/// Gets or sets the value of this node.
/// </summary>
public string NodeValue
{
get
{
return node.nodeValue();
}
set
{
node.setNodeValue(value);
}
}
/// <summary>
/// Gets the document that this node belongs to.
/// </summary>
public Document OwnerDocument
{
get
{
return Document.Create(node.ownerDocument());
}
}
/// <summary>
/// Gets the parent of this node.
/// </summary>
public Node ParentNode
{
get
{
return Node.Create(node.parentNode());
}
}
/// <summary>
/// Gets or sets the namespace prefix of this node.
/// </summary>
public string Prefix
{
get
{
return node.prefix();
}
set
{
node.setPrefix(value);
}
}
/// <summary>
/// Gets the node immediately preceding this one.
/// </summary>
public Node PreviousSibling
{
get
{
return Node.Create(node.previousSibling());
}
}
/// <summary>
/// Gets or sets the textual content of this node.
/// </summary>
public string TextContent
{
get
{
return node.textContent();
}
set
{
node.setTextContent(value);
}
}
#endregion
#region Node Object Methods
/// <summary>
/// Appends a new child node.
/// </summary>
/// <param name="NewChild">The node to append.</param>
/// <returns>The appended node.</returns>
public Node AppendChild(Node NewChild)
{
if (NewChild == null)
throw new ArgumentNullException();
return Node.Create(node.appendChild(NewChild.node));
}
/// <summary>
/// Clones this node.
/// </summary>
/// <param name="Deep">Indicates whether to clone all children of the original node.</param>
/// <returns>A clone of this node.</returns>
public Node CloneNode(bool Deep)
{
return Node.Create(node.cloneNode(Deep ? 1 : 0));
}
/// <summary>
/// Gets a value indicating whether this node has any attributes.
/// </summary>
public bool HasAttributes
{
get
{
return node.hasAttributes() != 0;
}
}
/// <summary>
/// Gets a value indicating whether this node has any children.
/// </summary>
public bool HasChildNodes
{
get
{
return node.hasChildNodes() != 0;
}
}
/// <summary>
/// Inserts a new node before an existing child node.
/// </summary>
/// <param name="NewChild">The node to insert.</param>
/// <param name="RefChild">The existing child node.</param>
/// <returns>The inserted node.</returns>
public Node InsertBefore(Node NewChild, Node RefChild)
{
if (NewChild == null || RefChild == null)
throw new ArgumentNullException();
return Node.Create(node.insertBefore(NewChild.node, RefChild.node));
}
/// <summary>
/// Checks if a node is equal to this one.
/// </summary>
/// <param name="Node">The node to check.</param>
/// <returns>A value indicating whether the nodes are equal.</returns>
public bool IsEqualNode(Node Node)
{
return node.isEqualNode((IDOMNode)Node.GetWebKitObject()) > 0;
}
/// <summary>
/// Checks if a node is the same as this one.
/// </summary>
/// <param name="Node">The node to check.</param>
/// <returns>A value indicating whether the nodes are the same.</returns>
public bool IsSameNode(Node Node)
{
return node.isSameNode((IDOMNode)Node.GetWebKitObject()) > 0;
}
/// <summary>
/// Checks whether a specified feature is supported on this node.
/// </summary>
/// <param name="Feature">The feature to check.</param>
/// <param name="Version">The feature version to check.</param>
/// <returns>A value indicating whether the specified feature is supported.</returns>
public bool IsSupported(string Feature, string Version)
{
return node.isSupported(Feature, Version) > 0;
}
/// <summary>
/// Removes a child node.
/// </summary>
/// <param name="OldChild">The child to remove.</param>
/// <returns>The removed node.</returns>
public Node RemoveChild(Node OldChild)
{
if (OldChild == null)
throw new ArgumentNullException();
return Node.Create(node.removeChild(OldChild.node));
}
/// <summary>
/// Replaces a child node with a new node.
/// </summary>
/// <param name="NewChild">The new node.</param>
/// <param name="OldChild">The node to be replaced.</param>
/// <returns>The new node.</returns>
public Node ReplaceChild(Node NewChild, Node OldChild)
{
if (NewChild == null || OldChild == null)
throw new ArgumentNullException();
return Node.Create(node.replaceChild(NewChild.node, OldChild.node));
}
#endregion
}
/// <summary>
/// Represents a DOM Attribute.
/// </summary>
public class Attr : Node
{
private IDOMAttr attr;
/// <summary>
/// Attr constructor.
/// </summary>
/// <param name="Attr">WebKit IDOMAttr object.</param>
protected Attr(IDOMAttr Attr)
: base(Attr)
{
this.attr = Attr;
}
internal static Attr Create(IDOMAttr Attr)
{
return new Attr(Attr);
}
#region Attr Object Properties
/// <summary>
/// Gets whether the attribute value is set in the document.
/// </summary>
public bool Specified
{
get
{
return attr.specified() > 0;
}
}
#endregion
}
/// <summary>
/// Represents a DOM Node containing character data.
/// </summary>
public class CharacterData : Node
{
private IDOMCharacterData characterData;
/// <summary>
/// CharacterData constructor.
/// </summary>
/// <param name="CharacterData">WebKit IDOMCharacterData object.</param>
protected CharacterData(IDOMCharacterData CharacterData)
: base(CharacterData)
{
this.characterData = CharacterData;
}
internal static CharacterData Create(IDOMCharacterData CharacterData)
{
if (CharacterData is IDOMComment)
return Comment.Create(CharacterData as IDOMComment);
else if (CharacterData is IDOMText)
return Text.Create(CharacterData as IDOMText);
else
return new CharacterData(CharacterData);
}
#region CharacterData Object Properties
/// <summary>
/// Gets or sets the data of this object.
/// </summary>
public string Data
{
get
{
return characterData.data();
}
set
{
characterData.setData(value);
}
}
/// <summary>
/// Gets the length of the data of this object.
/// </summary>
public int Length
{
get
{
return (int)characterData.length();
}
}
#endregion
#region CharacterData Object Methods
/// <summary>
/// Gets a substring of the specified length at the specified offset of the data.
/// </summary>
/// <param name="Offset">Offset of the data.</param>
/// <param name="Count">Length of the substring.</param>
/// <returns>The substring of data.</returns>
public string SubstringData(int Offset, int Count)
{
return characterData.substringData((uint)Offset, (uint)Count);
}
/// <summary>
/// Appends the specified data.
/// </summary>
/// <param name="Data">Data to append.</param>
public void AppendData(string Data)
{
characterData.appendData(Data);
}
/// <summary>
/// Deletes the substring of the specified length at the specified offset.
/// </summary>
/// <param name="Offset">Offset of the data.</param>
/// <param name="Count">Length of substring to delete.</param>
public void DeleteData(int Offset, int Count)
{
characterData.deleteData((uint)Offset, (uint)Count);
}
/// <summary>
/// Inserts the specified data at the specified offset of the original data.
/// </summary>
/// <param name="Offset">Offset of the data.</param>
/// <param name="Data">Data to insert.</param>
public void InsertData(int Offset, string Data)
{
characterData.insertData((uint)Offset, Data);
}
/// <summary>
/// Replaces the substring of the specified length at the specified offset with a new string.
/// </summary>
/// <param name="Offset">Offset of the data.</param>
/// <param name="Count">Length of the substring to replace.</param>
/// <param name="Data">The replacement data.</param>
public void ReplaceData(int Offset, int Count, string Data)
{
characterData.replaceData((uint)Offset, (uint)Count, Data);
}
#endregion
}
/// <summary>
/// Represents a DOM Comment.
/// </summary>
public class Comment : CharacterData
{
private IDOMComment comment;
/// <summary>
/// Comment constructor.
/// </summary>
/// <param name="Comment">WebKit IDOMComment object.</param>
protected Comment(IDOMComment Comment)
: base(Comment)
{
this.comment = Comment;
}
internal static Comment Create(IDOMComment Comment)
{
return new Comment(Comment);
}
}
/// <summary>
/// Represents a DOM Node containing text.
/// </summary>
public class Text : CharacterData
{
private IDOMText text;
/// <summary>
/// Text constructor.
/// </summary>
/// <param name="Text">WebKit IDOMText object.</param>
protected Text(IDOMText Text)
: base(Text)
{
this.text = Text;
}
internal static Text Create(IDOMText Text)
{
if (Text is IDOMCDATASection)
return CDATASection.Create(Text as IDOMCDATASection);
else
return new Text(Text);
}
/// <summary>
/// Splits the text node into two nodes at the specified offset.
/// </summary>
/// <param name="Offset">The offset of the text.</param>
/// <returns>A Text node containing the text after the offset.</returns>
public Text SplitText(int Offset)
{
return Text.Create(text.splitText((uint)Offset));
}
}
/// <summary>
/// Represents a CDATA section in a document.
/// </summary>
public class CDATASection : Text
{
private IDOMCDATASection cdataSection;
/// <summary>
/// CDATASection constructor.
/// </summary>
/// <param name="CDATASection">WebKit IDOMCDATASection object.</param>
protected CDATASection(IDOMCDATASection CDATASection)
: base(CDATASection)
{
this.cdataSection = CDATASection;
}
internal static CDATASection Create(IDOMCDATASection CDATASection)
{
return new CDATASection(CDATASection);
}
}
/// <summary>
/// Represents a DOM Document.
/// </summary>
public class Document : Node
{
private IDOMDocument document;
/// <summary>
/// Document constructor.
/// </summary>
/// <param name="Document">WebKit IDOMDocument object.</param>
protected Document(IDOMDocument Document)
: base(Document)
{
this.document = Document;
}
internal static Document Create(IDOMDocument Document)
{
return new Document(Document);
}
#region Document Object Properties
/// <summary>
/// Gets the Document Type Declaration associated with the document.
/// </summary>
public DocumentType DocType
{
get
{
return DocumentType.Create(document.doctype());
}
}
/// <summary>
/// Gets the DOM Implementation object that handles this document.
/// </summary>
public DocumentImpl Implementation
{
get
{
return DocumentImpl.Create(document.implementation());
}
}
#endregion
#region Document Object Methods
/// <summary>
/// Creates an attribute node with the specified name.
/// </summary>
/// <param name="Name">Name of the attribute.</param>
/// <returns>The new attribute node.</returns>
public Attr CreateAttribute(string Name)
{
return Attr.Create(document.createAttribute(Name));
}
/// <summary>
/// Cretaes an attribute node with the specified name and namespace.
/// </summary>
/// <param name="NamespaceURI">Namespace name of the attribute.</param>
/// <param name="Name">Name of the attribute.</param>
/// <returns>The new attribute node.</returns>
public Attr CreateAttributeNS(string NamespaceURI, string Name)
{
return Attr.Create(document.createAttributeNS(NamespaceURI, Name));
}
/// <summary>
/// Creates a comment node with the specified data.
/// </summary>
/// <param name="Data">Comment data.</param>
/// <returns>The new comment node.</returns>
public Comment CreateComment(string Data)
{
return Comment.Create(document.createComment(Data));
}
/// <summary>
/// Creates a CDATA section node with the specified data.
/// </summary>
/// <param name="Data">CDATA section data.</param>
/// <returns>The new CDATA section node.</returns>
public CDATASection CreateCDATASection(string Data)
{
return CDATASection.Create(document.createCDATASection(Data));
}
/// <summary>
/// Creates an empty document fragment object.
/// </summary>
/// <returns>The new document fragment.</returns>
public DocumentFragment CreateDocumentFragment()
{
return DocumentFragment.Create(document.createDocumentFragment());
}
/// <summary>
/// Creates a DOM Element with the specified tag name.
/// </summary>
/// <param name="TagName">The tag name for the new element.</param>
/// <returns>The new element.</returns>
public Element CreateElement(string TagName)
{
return Element.Create(document.createElement(TagName));
}
/// <summary>
/// Creates a DOM Element with the specified namespace and name.
/// </summary>
/// <param name="NamespaceURI">Namespace name for the element.</param>
/// <param name="QualifiedName">Name for the element.</param>
/// <returns>The new element.</returns>
public Element CreateElementNS(string NamespaceURI, string QualifiedName)
{
return Element.Create(document.createElementNS(NamespaceURI, QualifiedName));
}
/// <summary>
/// Creates an entity reference object with the specified name.
/// </summary>
/// <param name="Name">Name of the entity reference object.</param>
/// <returns>The new entity reference object.</returns>
public EntityReference CreateEntityReference(string Name)
{
return EntityReference.Create(document.createEntityReference(Name));
}
/// <summary>
/// Creates a processing instruction object with the specified target and data.
/// </summary>
/// <param name="Target">Target of the processing instruction.</param>
/// <param name="Data">Data of the processing instruction.</param>
/// <returns>The new processing instruction object.</returns>
public ProcessingInstruction CreateProcessingInstruction(string Target, string Data)
{
return ProcessingInstruction.Create(document.createProcessingInstruction(Target, Data));
}
/// <summary>
/// Creates a text node containing the specified textual data.
/// </summary>
/// <param name="Data">Textual data for the node.</param>
/// <returns>The new node.</returns>
public Text CreateTextNode(string Data)
{
return Text.Create(document.createTextNode(Data));
}
/// <summary>
/// Returns the first element with the specified id.
/// </summary>
/// <param name="id">The id of the element.</param>
/// <returns>Element with the specified id.</returns>
public Element GetElementById(string id)
{
return Element.Create(document.getElementById(id));
}
/// <summary>
/// Returns a collection containing all elements with the specified name.
/// </summary>
/// <param name="TagName">The name of the elements.</param>
/// <returns>A NodeList containing all elements with the specified name.</returns>
public NodeList GetElementsByTagName(string TagName)
{
return NodeList.Create(document.getElementsByTagName(TagName));
}
/// <summary>
/// Returns a collection containing all elements with the specified namespace and name.
/// </summary>
/// <param name="NamespaceURI">The namespace of the elements.</param>
/// <param name="LocalName">The name of the elements.</param>
/// <returns>A NodeList containing all elements with the specified namespace and name.</returns>
public NodeList GetElementsByTagNameNS(string NamespaceURI, string LocalName)
{
return NodeList.Create(document.getElementsByTagNameNS(NamespaceURI, LocalName));
}
/// <summary>
/// Imports a node from another document to this document.
/// </summary>
/// <param name="NodeToImport">The node to import.</param>
/// <param name="Deep">Value indicating whether to create a deep copy of the node.</param>
/// <returns>The imported node.</returns>
public Node ImportNode(Node NodeToImport, bool Deep)
{
return Node.Create(document.importNode((IDOMNode)NodeToImport.GetWebKitObject(), Deep ? 1 : 0));
}
/// <summary>