I have big problem:
I have informaton from two different xml files.
I get specified node by using GetElementsByTagName("appName");
I will then put this information in arraylist: arraylistA, arraylistB.
Then I compare the arraylist to find the difference. And the deference is also in an arraylist.
MY QUESTION IS HOW DO I IDENTIFED ALL THE ANOTHER NODES IN THAT ARRAYLIST:
Example:
<appsTable xmlns="http://tempuri.org/apps.xsd">
<application>
<appName>Microsoft Office Professional Edition 2003</appName>
<appInstallCmd>c:\WINDOWS\system32\MsiExec.exe</appInstallCmd>
<appVersionLocKey>SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90110409-6000-11D3-8CFE-0150048383C9}</appVersionLocKey>
<appVersionLocValue>DisplayVersion</appVersionLocValue>
</application>
<application>
<appName>Adobe Reader</appName>
<appInstallCmd>c:\WINDOWS\system32\MsiExec.exe</appInstallCmd>
<appVersionLocKey>SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-7AD7-1033-7646-A70000000000}</appVersionLocKey>
<appVersionLocValue>DisplayVersion</appVersionLocValue>
</application>
AFTER I COMPARE THE THE ARRAYLIST, THE RESULT IS:
Microsoft Office Professional Edition 2003
Adobe Reader
MY QUESTION IS HOW DO I ALSO GET THE appVersionLocKey associated with each node:So it will look like this:
Microsoft Office Professiona,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-7AD7-1033-7646-A70000000000
Adobe Reader,SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-7AD7-1033-7646-A70000000000

XMLNodeList + Arraylist
Len Smith
Use NextSibling property. The following code:
foreach
(XmlNode node in doc.GetElementsByTagName("appName")){Console.WriteLine(node.LocalName + "=" + node.InnerText);
XmlNode next = node.NextSibling;
Console.WriteLine(next.LocalName + "=" + next.InnerText);
next = next.NextSibling;
Console.WriteLine(next.LocalName + "=" + next.InnerText);
}
Produces the following output:
appName=Microsoft Office Professional Edition 2003
appInstallCmd=c:\WINDOWS\system32\MsiExec.exe
appVersionLocKey=SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90110409-6000-11D3-8CFE-0150048383C9}
appName=Adobe Reader
appInstallCmd=c:\WINDOWS\system32\MsiExec.exe
appVersionLocKey=SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-7AD7-1033-7646-A70000000000}
JJoergensen
Hello, 1234aaron
Thanks
But you can't convert nodelist to string
LJohnson
try creating a string that is the addition of the two node contents:
GetElements by tagname(application)
foreach...
string appname = application.SelectNodes("appname").InnerText;
string appVersionLocKey = application.SelectNodes("appVersionLocKey").InnerText;
string whatever = appName + appVersionLocKey
and put that in your array
try that or get the jist of that and do something similar