WebSquare.xml Package
Type
- engine
Property Summary
Event Summary
Method Summary
- appendChild( descNode , srcNode )
- Appends srcNode as a child node of desNode.
- decode( s )
- Decodes string characters including < > ' " & and \n.
- encode( s )
- Encodes string characters including & < > ' " CR and LF.
- findNode( doc , path )
- Searches the nodes of the corresponding XPath and returns the first node.
- findNodes( doc , path )
- Finds the nodes of the corresponding XPath and returns them as an array.
- getAttribute( doc , key , attribute )
- Searches an attribute of the corresponding document or element.
- getCDataNodeValue( element )
- Returns the CData node of the element, or null.
- getChildren( doc , key )
- Searches the child nodes of the corresponding XPath.
- getChildrenByTagName( element , name , uri )
- Returns the child nodes of the corresponding tag name.
- getFirstChildElement( element )
- Returns the first child node of the element.
- getFirstChildElements( element )
- Returns the child nodes of the element as an array.
- getString( doc , key )
- Gets the value attribute of the node element of the corresponding XPath.
- getTextNodeValue( element )
- Returns the Text node of the element, or null.
- getValue( doc , key , attribute )
- Searches the attribute or text node value of the XPath of the corresponding document or element.
- hasChildElement( domNode )
- Checks whether the element has child nodes or not.
- indent( obj , type )
- Converts XML document into XML string.
- parse( obj , namespace )
- Converts XML string into XML document.
- serialize( dom )
- Converts XML document into XML string.
- setAttribute( doc , key , value1 , value2 )
- Sets the attribute in the node element of the corresponding XPath.
- setString( doc , key , value )
- Sets the value attribute in the node element of the corresponding XPath.
- setValue( doc , key , value1 , value2 )
- Appends an attribute or Text node to the XPath node of the corresponding document or element.
Property Detail
Event Detail
Method Detail
- appendChild( descNode , srcNode )
-
Appends srcNode as a child node of desNode.
Parameter name type required description descNode Object Y Parent node srcNode Object Y Child node SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 J. K. Rowling "); var node2 = WebSquare.xml.findNode(doc, "author"); WebSquare.xml.appendChild( node1, node2 ); The following is node1.Harry Potter 29.99 J. K. Rowling - decode( s )
-
Decodes string characters including < > ' " & and \n.
Parameter name type required description s String Y String to decode Return type description String string SampleWebSquare.xml.decode("&"); - encode( s )
-
Encodes string characters including & < > ' " CR and LF.
Parameter name type required description s String Y String to encode Return type description String string SampleWebSquare.xml.encode( "&" ) - findNode( doc , path )
-
Searches the nodes of the corresponding XPath and returns the first node.
Parameter name type required description doc Document Y Document or Document Element (node) path String Y XPath string Return type description Object Document Element (node) or null SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 Harry Potter - findNodes( doc , path )
-
Finds the nodes of the corresponding XPath and returns them as an array.
Parameter name type required description doc Document Y Document or Document Element (node) path String Y Return type description Array Array of the document elements (or nodes) or null data SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 Harry Potter 29.99 Learning XML 39.95 - getAttribute( doc , key , attribute )
-
Searches an attribute of the corresponding document or element.
If the last argument (attribute) is not known, the second attribute of the current element (or the highest element of the document) will be used.
If the last attribute is not known, the second argument (key) will be used to search the node, and the last argument (attribute) will be used to search the attribute.Parameter name type required description doc Document Y Document or Document Element (node) key String Y XPath. If the attribute is not specified, the key will be used as the attribute. In this case, the key must consist of valid characters only. attribute String Y Name of the attribute to search. Return type description String Search result. If there is no search result, an empty string will be returned. SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 - getCDataNodeValue( element )
-
Returns the CData node of the element, or null.
Parameter name type required description element Object Y Document Element (node) Return type description String CDataNode value or null SampleBind the data with the model as shown below. Harry Potter 29.99 Stunning!]]>Learning XML 39.95 - getChildren( doc , key )
-
Searches the child nodes of the corresponding XPath.
The returns are as shown below:
[{"@tagName" : "Node" , "value" : "value1" } , {"@tagName" : "Node" , "value" : "value2" }]Parameter name type required description doc Document Y Document or Document Element (node) key String Y XPath string Return type description Array An object array of XML data SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 - getChildrenByTagName( element , name , uri )
-
Returns the child nodes of the corresponding tag name.
Parameter name type required description element Document Y Document or Document Element (node) name String Y nodeName string uri String Y namespace uri (If exists, the namespace will be also checked.) Return type description Array Array of the matching document elements (or nodes) SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 Harry Potter - getFirstChildElement( element )
-
Returns the first child node of the element.
Or returns null, if there is no element node.Parameter name type required description element Object Y Document Element (node) Return type description Object Document Element (node) or null SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 Harry Potter - getFirstChildElements( element )
-
Returns the child nodes of the element as an array.
If there is no element node, an empty array will be returned.Parameter name type required description element Object Y Document Element (node) Return type description Array An array of child elements (or nodes) SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 Harry Potter - getString( doc , key )
-
Gets the value attribute of the node element of the corresponding XPath.Gets the value attribute of the node element of the corresponding XPath.
Parameter name type required description doc Document Y Document or Document Element (node) key String Y XPath string Return type description String Search result. If there is no search result, an empty string will be returned. SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 - getTextNodeValue( element )
-
Returns the Text node of the element, or null.
Parameter name type required description element Object Y Document Element (node) Return type description String TextNode value or null SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 - getValue( doc , key , attribute )
-
Searches the attribute or text node value of the XPath of the corresponding document or element.
If the last argument (attribute) is not known, text node or CData node will be searched. Otherwise, the attribute will be searched.Parameter name type required description doc Document Y Document or Document Element (node) key String Y XPath string attribute String Y Name of the attribute. If not specified, Text node or CData node will be checked. Return type description String Search result. If there is no search result, an empty string will be returned. SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 - hasChildElement( domNode )
-
Checks whether the element has child nodes or not.
Parameter name type required description domNode Document Y Document or Document Element (node) Return type description Boolean Whether there is a childNode. SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 - indent( obj , type )
-
Converts XML document into XML string.
Supports line changing unlike serialize function.Parameter name type required description obj Document Y Character string to convert into XML string type String Y If not specified, WebSquare.xml.serialize will be executed. The result will include line changing. If the type is not undefined, the XML will be parsed in a recursive manner. Return type description String XML String Samplevar xmlDoc = WebSquare.xml.indent(" WebSquare ");WebSquare - parse( obj , namespace )
-
Converts XML string into XML document.
Parameter name type required description obj String Y Character string to convert into XML document namespace Boolean N Whether to parse the namespace or not Return type description Document XML Document Samplevar xmlDoc = WebSquare.xml.parse(" WebSquare ", false); - serialize( dom )
-
Converts XML document into XML string.
Parameter name type required description dom Document Y XML document to convert into XML string Return type description String XML String Samplevar xmlStr = WebSquare.xml.serialize(xmlDoc); - setAttribute( doc , key , value1 , value2 )
-
Sets the attribute in the node element of the corresponding XPath.
If the last argument (value2) is not specified, the attribute will be set in the current element (or in the highest-level element of the document).
If the last argument (value2) is specified, the attribute will be set in the node searched by the second argument (key) as the XPath.
Checks the attribute in the node element searched by XPathParameter name type required description doc Document Y Document or Document Element (node) key String Y If value2 is not specified, the key will be used as the attribute. In this case, the key must consist of valid characters only. value1 String Y Name of the attribute to set. If value2 is not specified, used as the value to set. value2 String Y Value to set SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 Harry Potter 29.99 - setString( doc , key , value )
-
Sets the value attribute in the node element of the corresponding XPath.
Parameter name type required description doc Document Y Document or Document Element (node) key String Y XPath string value String Y Value to set SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 Harry Potter 29.99 - setValue( doc , key , value1 , value2 )
-
Appends an attribute or Text node to the XPath node of the corresponding document or element.
If the last argument is not specified, value1 will be added to the Text node. Otherwise, value1 will become the name of the attribute.
If there is no node searched by XPath, a node will be created. In this case, XPath will contain only the node name.
If a node is not created, no operation will be made. (No error will occur either.)Parameter name type required description doc Document Y Document or Document Element (node) key String Y XPath string value1 String Y Name of the attribute to set the value. If value2 is not specified, value1 will be used as the Text node. value2 String Y Value to add. If not specified, Text node or CData node will be deleted and value1 will be added to the Text node. SampleBind the data with the model as shown below. Harry Potter 29.99 Learning XML 39.95 Harry Potter and the Philosopher's Stone 29.99