Changeset 10616
- Timestamp:
- 2005-09-21T17:15:26+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java
r10289 r10616 790 790 return filtered.toString(); 791 791 } 792 793 public static void printXMLNode(Node e) { 794 printXMLNode(e, 0) ; 795 } 796 797 public static void printXMLNode(Node e, int depth) { //recursive method call using DOM API... 798 799 for (int i=0 ; i<depth ; i++) 800 System.out.print(' ') ; 801 802 if (e.getNodeType() == Node.TEXT_NODE){ 803 System.out.println("text") ; 804 //System.out.println(e.getNodeValue()) ; 805 return ; 806 } 807 808 System.out.print('<'); 809 System.out.print(e.getNodeName()); 810 NamedNodeMap attrs = e.getAttributes(); 811 for (int i = 0; i < attrs.getLength(); i++) { 812 Node attr = attrs.item(i); 813 System.out.print(' '); 814 System.out.print(attr.getNodeName()); 815 System.out.print("=\""); 816 System.out.print(attr.getNodeValue()); 817 System.out.print('"'); 818 } 819 820 NodeList children = e.getChildNodes(); 821 822 if (children == null || children.getLength() == 0) 823 System.out.println("/>") ; 824 else { 825 826 System.out.println('>') ; 827 828 int len = children.getLength(); 829 for (int i = 0; i < len; i++) { 830 printXMLNode(children.item(i), depth + 1); 831 } 832 833 for (int i=0 ; i<depth ; i++) 834 System.out.print(' ') ; 835 836 System.out.println("</" + e.getNodeName() + ">"); 837 } 838 839 } 792 840 }
Note:
See TracChangeset
for help on using the changeset viewer.