## Xml

    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

### get

    HopObject get(<String> urlString)

Retrieves an XML document from a given URL and transforms it into a HopObject.
Syntax:

     Xml.get(urlString)
     Xml.get(urlString, filenameString)

The optional argument filenameString refers to a file containing a set of transformation rules how the XML data should be turned into a HopObject. Please take a look at the RFC for details.
Example:

     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#

Parameters:

`urlString` - as String, containing the URL to fetch the XML from

Returns:

HopObject

### getFromString

    HopObject getFromString(<String> xmlString)

Parses the string argument as XML and transforms it into a HopObject.
Syntax:

     Xml.getFromString(xmlString)
     Xml.getFromString(xmlString, filenameString)

The optional argument filenameString refers to a file containing a set of transformation rules how the XML data should be turned into a HopObject. Please take a look at the RFC for details.
Example:

     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

Parameters:

`xmlString` - as String in XML format

Returns:

HopObject

### read

    HopObject read()

Reads an XML tree from file and transforms it into a HopObject.
Syntax:

     Xml.read(filenameString)
     Xml.read(filenameString, HopObject)

If an optional HopObject is specified, the HopObject derived from the XML tree will be added to it.
Example:

     var obj = Xml.read("/tmp/dump.xml");
     res.write(obj);
     HopObject message

Parameters:

`String` -

Returns:

HopObject

### readFromString

    HopObject readFromString()

Reads an XML tree from a string and transforms it into a HopObject.
Syntax:

     Xml.readFromString(String)
     Xml.readFromString(String, HopObject)

If an optional HopObject is specified, the HopObject derived from the XML tree will be added to it.
Example:

     var f = new File("/tmp/dump.xml");
     var obj = Xml.readFromString(f.readAll());
     res.write(obj);
     HopObject message

Parameters:

`String` -

Returns:

HopObject

### write

    void write()

Dumps a HopObject as XML tree to a file.
Syntax:

     Xml.write(HopObject, filenameString)

Example:

     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><

Parameters:

`HopObject` - and file name as string

### writeToString

    String writeToString()

Stores a HopObject as XML tree in a string.
Syntax:

     Xml.writeToString(HopObject)

Example:

     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>

Parameters:

`HopObject` -

Returns:

String in XML encoded

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Documentation generated by JSDoc on Thu Apr 5 01:59:00 2007