just to add...
This is what i'm currently using:
XmlTextReader reader = new XmlTextReader(_fileName);
reader.WhitespaceHandling = WhitespaceHandling.None;
while(reader.Name != "Employee" && !reader.EOF)
reader.Read();
while(reader.Name == "Employee")
{
_shareCollection.Add(reader["name"]);
}
reader.Close();
Unfortunately, control never comes out of the while loop....
Hi,
Well, first, this is not valid XML as it has multiple root elements. It
should be something like this instead
<?xml version="1.0" encoding="utf-8"?>
<Employees>
<Employee name="john" />
<Employee name="peter" />
<Employee name="mark" />
</Employees>
You can then load it into an XmlDocument and use SelectNodes to grab the
Employees, and then read the name attribute
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\Employees.xml");
XmlNodeList elements = doc.SelectNodes("Employees/Employee");
ArrayList list = new ArrayList();
foreach (XmlNode node in elements)
list.Add(node.Attributes["name"].Value);
> Hi All,
>
[quoted text clipped - 8 lines]
>
> Thanks!

Signature
Happy Coding!
Morten Wennevik [C# MVP]
digitalshehan@gmail.com - 30 Aug 2006 08:27 GMT
Thanks Morten!
Appreciate the help... :)
> Hi,
>
[quoted text clipped - 33 lines]
> >
> > Thanks!
Peter Bromberg [C# MVP] - 30 Aug 2006 12:56 GMT
Morten,
Why is this invalid XML? I see an Employees root, and then multiple Employee
elements each with a name attribute. If I save this as "Test.xml" and load it
in Internet Exploder, it parses just fine.
Peter

Signature
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
> Hi,
>
[quoted text clipped - 33 lines]
> >
> > Thanks!
Morten Wennevik - 30 Aug 2006 13:00 GMT
Because, the original XML did NOT have an Employees root, but many
Employee roots.
> Morten,
> Why is this invalid XML? I see an Employees root, and then multiple
[quoted text clipped - 4 lines]
>
> Peter

Signature
Happy Coding!
Morten Wennevik [C# MVP]
Peter Bromberg [C# MVP] - 30 Aug 2006 19:19 GMT
Sorry,
It must have been your corrected version I was looking at!
Peter

Signature
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
> Because, the original XML did NOT have an Employees root, but many
> Employee roots.
[quoted text clipped - 7 lines]
> >
> > Peter