Class Xml

java.lang.Object
edu.tufts.hrilab.util.xml.Xml
All Implemented Interfaces:
Serializable

public class Xml extends Object implements Serializable
MZ: I obtained this XML code from an internet blog, with permission (see below) It is a very nice simple code, and makes XML parsing and writing easy. The code came from: http://stuffnwotnot.blogspot.com/2009/05/simple-way-to-parse-xml-in-java-2.html I contacted the author to make sure I can use his code in DIARC. As per the the author, Chris, (in one of the comments, in response to my comment): "Hi Michael, This code is completely free so please use it however you like!" The code below is actually an ever-so-slightly expanded version of his XML parsing code, and my own addition of the XML writing code
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • addAttribute

      public void addAttribute(String name, String value)
    • addChild

      public Xml addChild(Xml child)
      adds child based on child's name. returns the child for convenience: that way, can do Xml child = parent.addChild(new Xml("child"));
    • addChildren

      public void addChildren(List<Xml> children)
    • addChild

      public void addChild(String name, Xml child)
    • name

      public String name()
    • content

      public String content()
    • child

      public Xml child(String name)
    • childIfAny

      public Xml childIfAny(String name)
    • children

      public List<Xml> children(String name)
    • childNames

      public Set<String> childNames()
    • containsAttribute

      public boolean containsAttribute(String name)
    • string

      public String string(String name)
    • numInt

      public int numInt(String name)
    • numDouble

      public double numDouble(String name, ExpressionEvaluator evaluator, Substitution... additionalSubstitutions)
    • boolValue

      public boolean boolValue(String name)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • write

      public String write(String preIndent)
    • main

      public static void main(String[] args)
      for testing only: writing out an XML