The value of the nodes can be changed as follows:
If in case the node to be a Attribute, then the variable ‘Value’ will be the attribute value and in case the node to be a Text, the value will be the text content and for the Element the value will be null.
The node value settings for each type of the node like attribute, text node and element is demonstrated below:
The node.xml used in all the following examples is as below:
Changing the value of the Node element implies editing the text content of an element or a text node. The example demonstrating the change in the text node of the element is as follows:
An XML document, node.xml is parsed into an XML DOM object and the value of the text node of the element is changed. In the following example, Email of each of the Employee is changed to firstname.lastname@example.org and the values are printed.
The file is saved as set_text_node_example.htm on the server path and should be on the same path of the server as that of node.xml. The following output appears:
The change in the attribute node of the element is demonstrated below:
An XML document node.xml is parsed into an XML DOM object and the value of the element’s attribute node is changed. Here, the Category of each Employee is changed to admin-0, admin-1, admin-2 and the values are printed.
The file is saved as set_node_attribute_example.htm on the server path and should be on the same path of the server as that of node.xml. The following output appears:
XML DOM Related Interview Questions
|XML Interview Questions||HTML Interview Questions|
|CSS Interview Questions||XSLT Interview Questions|
|Java XML Interview Questions||XMLHttpRequest (XHR) Interview Questions|
|ebXML Interview Questions||XML DOM Interview Questions|
|XML-RPC Interview Questions||XSD Interview Questions|
|XSL Interview Questions||Xml Publisher Interview Questions|
Xml Dom Tutorial
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.