TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sander Groen
NA
12
0
Using xml to add controls
Jun 9 2010 10:45 AM
Hello all,
I like to use xml to add some controls to my application.
The problem is that my app uses only first match in the xml file instead of using all the nodes with the name knop.
I used a foreach loop but stil it does not use all the nodes.
What do i do wrong?
with regards Sander.
public Form1()
{
InitializeComponent();
dialoog = new editaction();
XmlDocument doc = new XmlDocument();
doc.Load("test.xml");
XmlNodeList List = doc.GetElementsByTagName("actions");
foreach (XmlNode node in List)
{
XmlElement knopElement = (XmlElement)node;
string item = knopElement.GetElementsByTagName("knop")[0].InnerText;
int positie = 10;
int tekst = 1;
create_button(item, positie, tekst);
positie += 50;
tekst += 1;
}
}
private void create_button(string xmltext, int positie, int tekst)
{
Button btn = new Button();
btn.Text = xmltext;
btn.Left = 50;
btn.Top = positie;
Label lbl = new Label();
lbl.Text = tekst.ToString();
lbl.Top = positie;
lbl.Left = 10;
pnlDefault.Controls.Add(btn);
pnlDefault.Controls.Add(lbl);
}
Reply
Answers (
8
)
Read atom feed with error of "Illegal characters in path"
Treeview from DataTable