Package edu.tufts.hrilab.util.xml
Class Xml
java.lang.Object
edu.tufts.hrilab.util.xml.Xml
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(String name, String value) adds child based on child's name.void
void
addChildren
(List<Xml> children) boolean
childIfAny
(String name) boolean
containsAttribute
(String name) content()
static void
for testing only: writing out an XMLname()
double
numDouble
(String name, ExpressionEvaluator evaluator, Substitution... additionalSubstitutions) int
toString()
-
Field Details
-
NEXT_LEVEL_INDENT
- See Also:
-
-
Constructor Details
-
Xml
- Throws:
FileNotFoundException
-
Xml
-
-
Method Details
-
addAttribute
-
addChild
adds child based on child's name. returns the child for convenience: that way, can do Xml child = parent.addChild(new Xml("child")); -
addChildren
-
addChild
-
name
-
content
-
child
-
childIfAny
-
children
-
childNames
-
containsAttribute
-
string
-
numInt
-
numDouble
public double numDouble(String name, ExpressionEvaluator evaluator, Substitution... additionalSubstitutions) -
boolValue
-
toString
-
write
-
main
for testing only: writing out an XML
-