XMLDocument
public class
system.xml.XMLDocument
Description
An XMLDocument binds together all the functionality. It can be saved, loaded, and printed to the screen. All XMLNodes are connected and allocated to an XMLDocument. If the XMLDocument is deleted, all its XMLNodes are also deleted.
API overview
Constructor
XMLDocument
()
Functions
Public functions
| deleteNode ( node: XMLNode ): Void |
native Delete a node associated with this document |
| getErrorStr1 (): String | native |
| getErrorStr2 (): String | native |
| loadFile ( filename: String ): Number |
native Load an XML file from the file system |
| newComment ( comment: String ): XMLComment |
native Create a new XMLComment associated with this XMLDocument |
| newDeclaration ( decl: String ): XMLDeclaration |
native Create a new XMLDeclaration associated with this XMLDocument |
| newElement ( name: String ): XMLElement |
native Create a new XMLElement associated with this XMLDocument |
| newText ( text: String ): XMLText |
native Create a new XMLText associated with this XMLDocument |
| parse ( xml: String ): Number |
native Parse an XML file from a String |
| print ( printer: XMLPrinter = null ): Void |
native Print the XMLDocument |
| rootElement (): XMLElement |
native Returns the root XMLElement of the DOM |
| saveFile ( filename: String ): Number |
native Save an XML file to the file system |
Constructor
XMLDocument ()
Functions
deleteChild
(
node: XMLNode
): Void
Inherited from XMLNode
native
Delete a child belonging to the XMLNode.
Parameters
| node: XMLNode | The XMLNode to delete. |
deleteNode ( node: XMLNode ): Void
native
Delete a node associated with this document. It will be unlinked from the DOM.
Parameters
| node: XMLNode | XMLNode to unlink from the DOM. |
firstChild
(): XMLNode
Inherited from XMLNode
native
Gets the first child XMLNode.
Returns
| XMLNode | The first child XMLNode or null if none exist. |
firstChildElement
(
name: String
= null
): XMLElement
Inherited from XMLNode
native
Get the first child XMLElement, or optionally the first child element with the specified name.
Parameters
| name: String = null | Optional name for finding the first child element by name. |
Returns
| XMLElement | First child XMLElement or null if none exist or if name does not match any child XMLElements. |
getDocument
(): XMLDocument
Inherited from XMLNode
native
Gets the XMLDocument that owns the XMLNode.
Returns
| XMLDocument | The owning XMLDocument. |
getFullTypeName
(): String
Inherited from Object
native
Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.
Returns
| String | fully qualified type name of the Object. |
getParent
(): XMLNode
Inherited from XMLNode
native
Gets the parent of this node in the DOM.
Returns
| XMLNode | The parent of this XMLNode or null if the XMLNode has no parent. |
getType
(): Type
Inherited from Object
native
Gets the Type that describes the Object.
Returns
| Type | The Type that describes the object. |
getTypeName
(): String
Inherited from Object
native
Gets the type name of the Object.
Returns
| String | type name of the Object. |
getValue
(): String
Inherited from XMLNode
native
Gets the value of the XMLNode. The meaning of 'value' changes based on the type.
Document: empty
Element: name of the element
Comment: the comment text
Unknown: the tag contents
Text: the text string
Returns
| String | The value of the XMLNode. |
insertAfterChild
(
afterThis: XMLNode
,
addThis: XMLNode
): XMLNode
Inherited from XMLNode
native
Add an XMLNode after the specified child node.
Parameters
| afterThis: XMLNode | The relative XMLNode. |
| addThis: XMLNode | The XMLNode to add. |
Returns
| XMLNode | The added XMLNode. |
insertEndChild
(
addThis: XMLNode
): XMLNode
Inherited from XMLNode
native
Add a child XMLNode as the last (right) child.
Parameters
| addThis: XMLNode | The XMLNode to add. |
Returns
| XMLNode | The added XMLNode. |
insertFirstChild
(
addThis: XMLNode
): XMLNode
Inherited from XMLNode
native
Add a child node as the first (left) child.
Parameters
| addThis: XMLNode | The XMLNode to add. |
Returns
| XMLNode | The added XMLNode. |
lastChild
(): XMLNode
Inherited from XMLNode
native
Gets the last child XMLNode.
Returns
| XMLNode | The last child XMLNode or null if none exist. |
lastChildElement
(
name: String
= null
): XMLElement
Inherited from XMLNode
native
Gets the last child XMLElement, or optionally the last child element with the specified name.
Parameters
| name: String = null | Optional name for finding the last child element by name. |
Returns
| XMLElement | First child XMLElement or null if none exist or if name does not match any child XMLElements. |
linkEndChild
(
addThis: XMLNode
): XMLNode
Inherited from XMLNode
native
Parameters
| addThis: XMLNode |
loadFile ( filename: String ): Number
native
Load an XML file from the file system.
Parameters
| filename: String | The file to load. |
Returns
| Number | XMLError.XML_NO_ERROR (0) on success, or an XMLError. |
newComment ( comment: String ): XMLComment
native
Create a new XMLComment associated with this XMLDocument. The memory for the XMLComment is managed by the XMLDocument.
Parameters
| comment: String | The text of the comment. |
Returns
| XMLComment | The new XMLComment. |
newDeclaration ( decl: String ): XMLDeclaration
native
Create a new XMLDeclaration associated with this XMLDocument. The memory for the XMLDeclaration is managed by the XMLDocument.
Parameters
| decl: String | Text of the new declaration. |
Returns
| XMLDeclaration | The new XMLDeclaration. |
newElement ( name: String ): XMLElement
native
Create a new XMLElement associated with this XMLDocument. The memory for the XMLElement is managed by the XMLDocument.
Parameters
| name: String | The name of the new XMLElement. |
Returns
| XMLElement | The new XMLElement. |
newText ( text: String ): XMLText
native
Create a new XMLText associated with this XMLDocument. The memory for the XMLText is managed by the XMLDocument.
Parameters
| text: String | The new xml text. |
Returns
| XMLText | The new XMLText. |
nextSibling
(): XMLNode
Inherited from XMLNode
native
Gets the next (right) sibling XMLNode of this node.
Returns
| XMLNode | Next sibling XMLNode or null if none exist. |
nextSiblingElement
(
name: String
= null
): XMLElement
Inherited from XMLNode
native
Gets the next (right) sibling XMLElement of this node.
Parameters
| name: String = null | Optional name for finding the next sibling element by name. |
Returns
| XMLElement | Next sibling XMLNode or null if none exist. |
native
Parse an XML file from a String.
Parameters
| xml: String | The XML to parse. |
Returns
| Number | XMLError.XML_NO_ERROR (0) on success, or an XMLError. |
previousSibling
(): XMLNode
Inherited from XMLNode
native
Gets the previous (left) sibling XMLNode of this node.
Returns
| XMLNode | Previous sibling XMLNode or null if none exist. |
previousSiblingElement
(
name: String
= null
): XMLElement
Inherited from XMLNode
native
Get the previous (left) sibling XMLElement of this node.
Parameters
| name: String = null | Optional name for finding the previous sibling element by name. |
Returns
| XMLElement | Previous sibling XMLNode or null if none exist. |
print ( printer: XMLPrinter = null ): Void
native
Print the XMLDocument. If an XMLPrinter is not provided, it will print to stdout. If you provide an XMLPrinter, it can print to a file.
Parameters
| printer: XMLPrinter = null | XMLPrinter to print to a file. |
rootElement (): XMLElement
native
Returns the root XMLElement of the DOM. Equivalent to firstChildElement(). To get the first node, use firstChild().
Returns
| XMLElement | The root XMLElement of the DOM. |
saveFile ( filename: String ): Number
native
Save an XML file to the file system.
Parameters
| filename: String | The file to save. |
Returns
| Number | XMLError.XML_NO_ERROR (0) on success, or an XMLError. |
setValue
(
v: String
,
staticMem: Boolean
= false
): Void
Inherited from XMLNode
native
Sets the value of the XMLNode.
See also:
getValue
Parameters
| v: String | The value to set. |
| staticMem: Boolean = false |
shallowClone
(
doc: XMLDocument
): XMLNode
Inherited from XMLNode
native
Make a copy of this XMLNode, but not its children. You may pass in a Document pointer that will be the owner of the new Node. If the 'document' is null, then the node returned will be allocated from the current Document. (this.getDocument())
@note If called on an XMLDocument, this will return null.
Parameters
| doc: XMLDocument | The owner of the new XMLNode. |
Returns
| XMLNode | Shallow copy of the XMLNode or null if called on a XMLDocument. |
shallowEqual
(
compare: XMLNode
): Boolean
Inherited from XMLNode
native
Test if 2 XMLNode%s are the same, but don't test children. The 2 nodes do not need to be in the same XMLDocument.
@note If called on an XMLDocument, this will return false.
Parameters
| compare: XMLNode | The XMLNode to compare to. |
Returns
| Boolean | Whether or not the XMLNode%s are shallow equals. |
toComment
(): XMLComment
Inherited from XMLNode
native
Safely cast to an XMLComment.
Returns
| XMLComment | The casted XMLComment or null if the cast was unsuccessful. |
toDeclaration
(): XMLDeclaration
Inherited from XMLNode
native
Safely cast to an XMLDeclaration.
Returns
| XMLDeclaration | The casted XMLDeclaration or null if the cast was unsuccessful. |
toDocument
(): XMLDocument
Inherited from XMLNode
native
Safely cast to an XMLDocument.
Returns
| XMLDocument | The casted XMLDocument or null if the cast was unsuccessful. |
toElement
(): XMLElement
Inherited from XMLNode
native
Safely cast to an XMLElement.
Returns
| XMLElement | The casted XMLElement or null if the cast was unsuccessful. |