Comparing two xml files
-
hi all, I want to compare 2 xml files with each other. One xml file is standard on my pc and has the name standard.xml. the other xml file is on the server and has the name server.xml i want to compare these 2 files with each other and if it contains new info it should be added in the pc.xml file. in msdn, i found that XML diff and patch tool is used to compare two xml files. but i do not want to add a additional tool to be installed for this purpose. i tried to do the comparison by getting the nodes in a XmlNodeList and comparing the two nodelists. but i am struck at one point. how can i find out whether a node already exists in a xml document. say for eg, in my xml file,i have a structure like this, <Main> <url type_node="S" tool_tip="http://www.mysite.com/sample.xml">http://www.mysite.com/sample.xml</url> <Category2> <url type_node="S" tool_tip="http://www.mysite.com/sample1.xml">http://www.mysite.com/sample1.xml</url> </Category2> </Main> in this, Category2 is a childnode of Main. i want to check if the url element for sample exists already in the document. how can i do this. i tried using xmldoc.getElementsByTagName(node.innerText); but i am always getting a count of 1 even if the node does not exits in the document. Hope i am clear in my question. Any suggestions?
Thanks in advance.:) Regards Anuradha
-
hi all, I want to compare 2 xml files with each other. One xml file is standard on my pc and has the name standard.xml. the other xml file is on the server and has the name server.xml i want to compare these 2 files with each other and if it contains new info it should be added in the pc.xml file. in msdn, i found that XML diff and patch tool is used to compare two xml files. but i do not want to add a additional tool to be installed for this purpose. i tried to do the comparison by getting the nodes in a XmlNodeList and comparing the two nodelists. but i am struck at one point. how can i find out whether a node already exists in a xml document. say for eg, in my xml file,i have a structure like this, <Main> <url type_node="S" tool_tip="http://www.mysite.com/sample.xml">http://www.mysite.com/sample.xml</url> <Category2> <url type_node="S" tool_tip="http://www.mysite.com/sample1.xml">http://www.mysite.com/sample1.xml</url> </Category2> </Main> in this, Category2 is a childnode of Main. i want to check if the url element for sample exists already in the document. how can i do this. i tried using xmldoc.getElementsByTagName(node.innerText); but i am always getting a count of 1 even if the node does not exits in the document. Hope i am clear in my question. Any suggestions?
Thanks in advance.:) Regards Anuradha
Can you explain it more.may be i can help.