User Tools

Site Tools


DzDomDocument

Represents a Document Object Model (DOM) “Document”.

More...

Inherits :

Constructors

DAZ Script
DzDomDocument ()
DzDomDocument ( String nsURI, String qName, String publicId, String systemId )

Methods

Detailed Description

A script wrapper for QDomDocument. This object represents an entire DOM document. Conceptually, it is the root of the document tree and provides the primary access to the document's data.

This is the only DzDomNode derived object that is constructed directly.

To populate a document, use loadContent() to cause data to be parsed from an XML (or XML derivative) file, or use setContent() to cause data to be parsed from an XML (or XML derivative) string.

Note that it is also possible to create nodes of the DOM tree from scratch by using the following factory functions:

The parsed XML data is represented by an internal tree of nodes that can be accessed using DzDomNode (and derived) objects. The internal objects in the DOM tree are deleted once the last DOM object referencing them and the DzDomDocument itself are deleted.

For more information about the Document Object Model (DOM) see the Level 1 and Level 2 Core specifications.

Constructors


DzDomDocument()

Default constructor.

Return Value:

  • An empty DOM document.

DzDomDocument( String nsURI, String qName, String publicId, String systemId )

Parameter(s):

  • nsURI - The namespace of the root element (if any).
  • qName - The qualified name of the root element to create.
  • publicId - The public identifier of an external subset (if any). Passing an empty string means that the document type has no public identifier.
  • systemId - The system identifier of an external subset (if any). Passing an empty string means that the document type has no system identifier.

Return Value:

  • A DOM document in the nsURI namespace, with a root element named qName, and a document type of qName with the public identifier of.publicId and the system identifier systemId.

Attention:

  • Since a public identifier without a system identifier is invalid, the public identifier is set to an empty string if there is no system identifier.

Since:

  • 4.20.0.10

Methods


DzDomAttr : createAttribute( String name )

Parameter(s):

  • name - The name of the “Attribute” to create.

Return Value:

  • A new “Attribute” node that is a member of this document.

Attention:

See Also:


DzDomAttr : createAttributeNS( String nsURI, String qName )

Parameter(s):

  • nsURI - The namespace of the “Attribute” to create.
  • qName - The qualified name of the “Attribute” to create.

Return Value:

  • A new “Attribute” node, in the specified namespace, that is a member of this document.

Attention:

See Also:


DzDomCDATASection : createCDATASection( String value )

Parameter(s):

  • value - The string value to store in the document.

Return Value:

  • A new “Character Data Section” node that is a member of this document.

Attention:

  • The node must still be added it as a child of the document or one of its nodes.

See Also:


DzDomComment : createComment( String value )

Parameter(s):

  • value - The text of the comment.

Return Value:

  • A new “Comment” node that is a member of this document.

Attention:

  • The node must still be added it as a child of the document or one of its nodes.

See Also:


DzDomDocumentFragment : createDocumentFragment()

Return Value:

  • A new “Document Fragment” node that is a member of this document.

Attention:

  • The node must still be added it as a child of the document or one of its nodes.

See Also:


DzDomElement : createElement( String tagName )

Parameter(s):

  • tagName - The name of the “Element” node to create.

Return Value:

  • A new “Element” node that is a member of this document.

Attention:

  • The node must still be added it as a child of the document or one of its nodes.

See Also:


DzDomElement : createElementNS( String nsURI, String qName )

Parameter(s):

  • nsURI - The namespace of the “Element” to create.
  • qName - The qualified name of the “Element” to create.

Return Value:

  • A new “Element” node, in the specified namespace, that is a member of this document.

Attention:

  • The node must still be added it as a child of the document or one of its nodes.

See Also:


DzDomEntityReference : createEntityReference( String name )

Parameter(s):

  • name - The name of the “Entity Reference” to create.

Return Value:

  • A new “Entity Reference” node that is a member of this document.

Attention:

  • The node must still be added it as a child of the document or one of its nodes.

See Also:


DzDomProcessingInstruction : createProcessingInstruction( String target, String data )

Parameter(s):

  • target - The target of the processing instruction.
  • data - The data to be processed.

Return Value:

  • A new “Processing Instruction” node that is a member of this document.

Attention:

  • The node must still be added it as a child of the document or one of its nodes.

See Also:


DzDomText : createTextNode( String value )

Parameter(s):

  • value - The text to store in the node.

Return Value:

  • A new “Text” node that is a member of this document.

Attention:

  • The node must still be added it as a child of the document or one of its nodes.

See Also:


DzDomDocumentType : doctype()

Return Value:


DzDomElement : documentElement()

Return Value:

Since:

  • 4.20.0.10

DzDomNode : elementById( String id )

Parameter(s):

  • elementId - The ID of the element to retrieve.

Return Value:

  • The element whose ID is equal to elementId (if any), otherwise a null element.

Attention:

  • Since the underlying QDom classes do not know which attributes are element IDs, this method always returns a null element. This may change in a future version.

DzDomNode : importNode( DzDomNode node, Boolean deep )

Parameter(s):

  • node - The node to import.
  • deep - If true, node and all of its children are imported recursively. If false, only node is imported.

Return Value:

  • A new node that is a member of this document that is a (deep) copy of the specified node.

Attention:

  • The node must still be added it as a child of the document or one of its nodes.

See Also:


Boolean : loadContent( String filename )

Sets the contents of the document by parsing the file at the specified path.

Parameter(s):

  • filename - The (absolute) path of the file to load.

Return Value:

  • true if the file was successfully parsed, otherwise false.

Boolean : saveContent( String filename )

Saves the contents of the document to the specified file.

Parameter(s):

  • filename - The (absolute) path of the file to save.

Return Value:

  • true if the file was successfully saved, otherwise false.

Boolean : setContent( String text )

Sets the contents of this document from the specified string.

Parameter(s):

  • text - The XML document, in string form, to set the contents of this document to; assumed to be a Unicode string, no encoding detection is performed.

Return Value:

  • true if the string was successfully parsed, otherwise false.

See Also:


ByteArray : toByteArray( Number indent=1 )

Parameter(s):

  • indent - The amount of space to indent sub-elements.

Return Value:

  • The contents of this document in its textual representation as a byte array, encoded as UTF-8.

Since:

  • 4.11.0.155

String : toString( Number indent=1 )

Parameter(s):

  • indent - The amount of space to indent sub-elements. (since 4.11.0.155)

Return Value:

  • The contents of the document in its textual representation.