hello I got this xml file
Tanya Milenova Marinova Plovdiv 4000, bul. Vasil Aprilov 115 0899803698
So I try to read the xml file line by line and get element name or attribute name in a label - and the element value or attribute value in a textbox (so that the user can make changes)
int i = 0;
XmlTextReader rdr = new XmlTextReader("E:/Tanya Documents/Stanga1Projects/XML_project_Tanya_Marinova/cv.xml");
while (rdr.Read())
{
if (rdr.NodeType == XmlNodeType.Element)
{
Label nodeName = new Label();
nodeName.Text = rdr.LocalName+": ";
Page.FindControl("form1").Controls.Add(nodeName);
if (i != 1)
{
XmlReader pReader = rdr.ReadSubtree();
while (pReader.Read())
{
if (pReader.NodeType == XmlNodeType.Text)
{
TextBox txtBox = new TextBox();
txtBox.Text = rdr.Value;
Page.FindControl("form1").Controls.Add(txtBox);
}
if (pReader.NodeType == XmlNodeType.Element)
{
for (int t = 0; t < rdr.AttributeCount; t++)
{
/* ...Here I want a label with attribute name not value)*/
TextBox txbAttribute = new TextBox();
txbAttribute.Text = rdr.GetAttribute(t);
Page.FindControl("form1").Controls.Add(txbAttribute);
}
}
}
}
Page.FindControl("form1").Controls.Add(new LiteralControl("<br />"));
}
i++;
}
Everything works fine but when I get to 'education' element - which has childNodes - element with attributes - I can get only attribute value with 'getAttributes' method but I can't get their name
Thank you very much