Siva wrote:
I am a rookie to the field of xml but I have a pressing issue that I hope
you can help with.
I have an xml document (say runs.xml). I would like to load it in my Vb .net
app and search for the presence of a certain attribute value. This xml file
would have user information along with their login ID.
How can I use system.xml to read this file and check the existence of an
atrribute value.? Any samples would be appreciated.
The following is a simple C# command line program reading a value from
the command line and looking for attributes with that value:
using System;
using System.Xml;
public class Test20040221 {
public static void Main (string[] args) {
XmlTextReader xmlReader = new XmlTextReader("test20040221.xml");
while (xmlReader.Read()) {
if (xmlReader.HasAttributes) {
while (xmlReader.MoveToNextAttribute()) {
if (xmlReader.Value == args[0]) {
Console.WriteLine("Found value in attribute named {0}.",
xmlReader.Name);
}
}
}
}
}
}
Hopefully you are able to convert that to VB.NET, you simply need to
check if the current node HasAttributes and then you loop while
MoveToNextAttribute() returns true. Maybe you want to break once you
have found the attribute, the above example however continues to look
for further matches.
--
Martin Honnen
http://JavaScript.FAQTs.com/