1 19 20 25 26 27 package soot.xml; 28 29 30 31 public class XMLRoot 32 { 33 public String name = ""; public String value = ""; public String [] attributes = { "" }; public String [] values = { "" }; 38 protected XMLNode child = null; 40 XMLRoot() 41 { 42 } 43 44 public String toString() 45 { 46 return XMLPrinter.xmlHeader + XMLPrinter.dtdHeader + this.child.toPostString(); 47 } 48 49 public XMLNode addElement( String name ) 51 { 52 return addElement( name, "", "", "" ); 53 } 54 public XMLNode addElement( String name, String value ) 55 { 56 return addElement( name, value, "", "" ); 57 } 58 public XMLNode addElement( String name, String value, String [] attributes ) 59 { 60 return addElement( name, value, attributes, null ); 61 } 62 public XMLNode addElement( String name, String [] attributes, String [] values ) 63 { 64 return addElement( name, "", attributes, values ); 65 } 66 public XMLNode addElement( String name, String value, String attribute, String attributeValue ) 67 { 68 return addElement( name, value, new String [] { attribute}, new String [] { attributeValue} ); 69 } 70 public XMLNode addElement( String name, String value, String [] attributes, String [] values ) 71 { 72 XMLNode current= null; 73 XMLNode newnode = new XMLNode( name, value, attributes, values ); 74 newnode.root = this; 75 76 if( this.child == null ) 77 { 78 this.child = newnode; 79 newnode.parent = null; } 81 else 82 { 83 current = this.child; 84 while( current.next != null ) 85 { 86 current = current.next; 87 } 88 current.next = newnode; 89 newnode.prev = current; 90 } 91 return newnode; 92 } 93 } 94 | Popular Tags |