Object | +--Xml
| SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods |
| Methods Summary | |
HopObject
|
get(<String> urlString)
Retrieves an XML document from a given URL and transforms it into a HopObject. |
HopObject
|
getFromString(<String> xmlString)
Parses the string argument as XML and transforms it into a HopObject. |
HopObject
|
read()
Reads an XML tree from file and transforms it into a HopObject. |
HopObject
|
readFromString()
Reads an XML tree from a string and transforms it into a HopObject. |
void
|
write()
Dumps a HopObject as XML tree to a file. |
String
|
writeToString()
Stores a HopObject as XML tree in a string. |
| Method Detail |
HopObject get(<String> urlString)
Xml.get(urlString) Xml.get(urlString, filenameString)
var obj = Xml.get("http://localhost:8080/antville/rss10");
for (var i in obj)
res.writeln(i + ": " + obj[i]);
xmlns_sy: http://purl.org/rss/1.0/modules/syndication/
xmlns_dc: http://purl.org/dc/elements/1.1/
item: HopObject item
channel: HopObject channel
xmlns: http://purl.org/rss/1.0/
xmlns_rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
urlString - as String, containing the URL to fetch the XML from
HopObject getFromString(<String> xmlString)
Xml.getFromString(xmlString) Xml.getFromString(xmlString, filenameString)
var obj = Xml.getFromString("<a>hello <b>world</b></a>");
for (var i in obj)
res.writeln(i + ": " + obj[i]);
b: HopObject b
text: hello
xmlString - as String in XML format
HopObject read()
Xml.read(filenameString) Xml.read(filenameString, HopObject)
var obj = Xml.read("/tmp/dump.xml");
res.write(obj);
HopObject message
String -
HopObject readFromString()
Xml.readFromString(String) Xml.readFromString(String, HopObject)
var f = new File("/tmp/dump.xml");
var obj = Xml.readFromString(f.readAll());
res.write(obj);
HopObject message
String -
void write()
Xml.write(HopObject, filenameString)
var obj = new message(); obj.title = "The Message"; obj.text = "Don't push me 'cause I'm close to the edge."; root.add(obj); Xml.write(obj, "/tmp/dump.xml"); File /tmp/dump.xml: <?xml version="1.0"?> <!-- printed by helma object publisher --> <!-- created Fri Jul 12 17:25:24 CEST 2002 --> <xmlroot xmlns:hop="http://www.helma.org/docs/ guide/features/database"> <hopobject id="8" name="message" prototype="message" created="1026487524440" lastModified="1026487524440"> <hop:parent idref="0" prototyperef="root"/> <title>The Message</title> <text>Don't push me 'cause I'm close to the edge.</text> </hopobject> </xmlroot><
HopObject - and file name as string
String writeToString()
Xml.writeToString(HopObject)
var str = Xml.writeToString(this.get(0)); res.write(str); <?xml version="1.0"?> <!-- printed by helma object publisher --> <!-- created Fri Jul 12 17:25:24 CEST 2002 --> <xmlroot xmlns:hop="http://www.helma.org/docs/ guide/features/database"> <hopobject id="8" name="message" prototype="message" created="1026487524440" lastModified="1026487524440"> <hop:parent idref="0" prototyperef="root"/> <title>The Message</title> <text>Don't push me 'cause I'm close to the edge.</text> </hopobject> </xmlroot>
HopObject -
| SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods |