I load an XML document using XMLHTTPRequest in my js file. the XML file is like below:
<?xml version="1.0" encoding="utf-8"?> <RMFSFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Host>www.example.com</Host> <Port>8888</Port> <Uri>www.example.com</Uri> <Path> <HD> <UNC>path1</UNC> </HD> <SD> <UNC>path2</UNC> </SD> </Path> I am now trying to first select Path1, and Path2 nodes, and then switch the value of path1 with the value of path2. I select the nodes like below:
var firstNode = xmlFile.querySelector('Path>HD>UNC'); \\ I can get the node successfully. var secondNode= xml.querySelector('Path>SD>UNC'); \\ I can get the node successfully. However, when I try to replace the values by using the following code:
xmlFile.replaceChild(secondNode,firstNode) // secondNode, is the new value for first node. I get an error says,"An attempt was made to reference a Node in a context where it does not exist". Any Idea where I am doing it wrong?
No comments:
Post a Comment