XML ComboBox

T

Thom Little

I would like to have a combobox populated with the ID in each node of an XML
file. Is there a preferred way to do this? What was the source of your
information?

A stripped down copy of the XML file is ...

<?xml version="1.0" encoding="utf-8"?>
<profiles>
<profile>
<id>One</id>
<buyer>X</buyer>
<card>X</card>X<seller>X</seller>
</profile>
<profile>
<id>Two</id>
<buyer>X</buyer>
<card>X</card>X<seller>X</seller>
</profile>
</profiles>

.... I would like the combobox entries to contain the names "One" and "Two".
 
T

Thom Little

Solution ...

XmlDocument document = new XmlDocument( );

document.Load( "c:\somedir\somefile.xml" );

XmlElement root = document.DocumentElement ;

XmlNodeList nodelist = root.SelectNodes( "//profile/id" );

foreach ( XmlNode node in nodelist )

cbProfileId.Items.Add( node.InnerXml );


.... and is particularly useful for setting up a LARGE configuration area
outside the Registry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top