예제 #1
0
 public void appendChild(Node node)
 {
     if(node==this)
       throw new ArgumentException();
     node.parentNode=this;
     node.ownerDocument=(this is IDocument) ? (IDocument)this : ownerDocument;
     childNodes.Add(node);
 }
예제 #2
0
 private Text getTextNodeToInsert(Node node)
 {
     IList<Node> childNodes=node.getChildNodesInternal();
       Node lastChild=(childNodes.Count==0) ? null : childNodes[childNodes.Count-1];
       if(lastChild==null || lastChild.getNodeType()!=NodeType.TEXT_NODE){
     Text textNode=new Text();
     node.appendChild(textNode);
     return textNode;
       } else
     return ((Text)lastChild);
 }
예제 #3
0
 public void removeChild(Node node)
 {
     node.parentNode=null;
     childNodes.Remove(node);
 }
예제 #4
0
 public void insertBefore(Node child, Node sibling)
 {
     if(sibling==null){
       appendChild(child);
       return;
     }
     if(childNodes.Count==0)
       throw new InvalidOperationException();
     int childNodesSize=childNodes.Count;
     for(int j=0;j<childNodesSize;j++){
       if(childNodes[j].Equals(sibling)){
     child.parentNode=this;
     child.ownerDocument=(child is IDocument) ? (IDocument)this : ownerDocument;
     childNodes.Insert(j,child);
     return;
       }
     }
     throw new ArgumentException();
 }