class SAPO.Utility.XML
Namespace with a set of xml utility functions
Defined in Utility/XML/0.1/lib.js

Function Summary
Document ownerDocument (Node node)
Returns the document that owns the node
DocumentFragment parseHTMLFragment (Node contextNode, String xmlStr)
Parses a html fragment into a dom fragment within a given document. Unlike parseHTMLNode, the returned fragment can have multiple nodes on the fragment root.
Element parseHTMLNode (Node contextNode, String htmlStr)
Parses a html fragment into a dom node within a given document.
Document parseXMLDocument (String xmlStr)
Parses a xml fragment into astandalone document.
DocumentFragment parseXMLFragment (Node contextNode, String xmlStr)
Parses a xml fragment into a dom fragment within a given namespace context and document. Unlike parseXMLNode, the returned fragment can have multiple nodes on the fragment root.
Element parseXMLNode (Node contextNode, String xmlStr)
Parses a xml fragment into a dom node within a given namespace context and document.
String serialize (Node node, Boolean deep)
Serializes the given node into a xml string
Encodes all special xml, control and non ascii chars into entities

Function Details

function ownerDocument

Document ownerDocument(Node node)
Returns the document that owns the node
Parameters:
node to fetch ownerDocument from
Returns:
{Document} the ownerDocument

function parseHTMLFragment

DocumentFragment parseHTMLFragment(Node contextNode, String xmlStr)
Parses a html fragment into a dom fragment within a given document. Unlike parseHTMLNode, the returned fragment can have multiple nodes on the fragment root.
Parameters:
contextNode context node. It's used to know the ownerDocument of the resulting tree and any inherited namespaces.
xmlStr the xml string to parse
Returns:
{DocumentFragment} the parsed tree

function parseHTMLNode

Element parseHTMLNode(Node contextNode, String htmlStr)
Parses a html fragment into a dom node within a given document.
Parameters:
contextNode context node. It's used to know the ownerDocument of the resulting tree and any inherited namespaces.
htmlStr the html string to parse
Returns:
{Element} the parsed tree

function parseXMLDocument

Document parseXMLDocument(String xmlStr)
Parses a xml fragment into astandalone document.
Parameters:
xmlStr the xml string to parse
Returns:
{Document} the parsed document

function parseXMLFragment

DocumentFragment parseXMLFragment(Node contextNode, String xmlStr)
Parses a xml fragment into a dom fragment within a given namespace context and document. Unlike parseXMLNode, the returned fragment can have multiple nodes on the fragment root.
Parameters:
contextNode context node. It's used to know the ownerDocument of the resulting tree and any inherited namespaces.
xmlStr the xml string to parse
Returns:
{DocumentFragment} the parsed tree

function parseXMLNode

Element parseXMLNode(Node contextNode, String xmlStr)
Parses a xml fragment into a dom node within a given namespace context and document.
Parameters:
contextNode context node. It's used to know the ownerDocument of the resulting tree and any inherited namespaces.
xmlStr the xml string to parse
Returns:
{Element} the parsed tree

function serialize

String serialize(Node node, Boolean deep)
Serializes the given node into a xml string
Parameters:
node node to serialize
deep if false, only serializes the given node, else it serializes the whole subtree.
Returns:
{String} the xml string

function xmlEncodeEntities

String xmlEncodeEntities(String xmlStr)
Encodes all special xml, control and non ascii chars into entities
Parameters:
xmlStr the string to encode
Returns:
{String} the encoded string with entities