//pi array takes the attributes of the scon XML element
Code
PropertyInfo[] pi = scon.GetType(.GetProperties();
Code
Code
for (int i = 0; i < pi.Length; i++)
Code
{
Code
//I want to create objects automatically from the vales within the pi array !!!
XmlElement PropertyList[i] = xmlDoc.CreateElement(pi[i].ToString());
}
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Vishal JadavRank #1,692 · 901 reputationPosted Jun 20, 2011, 3:52 AM EDT
0
Hey buddy,
you have created xmlelement in the loop , but u may have not added it to xmldocument.
Try it ...
0
Sam HobbsRank #107 · 20.5K reputationPosted Jun 20, 2011, 11:24 PM EDT
0
Do you need a list of names and only names? Do you need the list to be in C# code or do you need the list to be in HTML or XML?
If you need this to be in C# code, then do you need for there to be a value associated each name? For example, do you need both a property name and a property value?
Perhaps you need to use a C# array or a List or ArrayList or Dictionary or some other collection.
Vishal JadavRank #1,692 · 901 reputationPosted Jun 20, 2011, 3:52 AM EDT
you have created xmlelement in the loop , but u may have not added it to xmldocument.
Try it ...
Sam HobbsRank #107 · 20.5K reputationPosted Jun 20, 2011, 11:24 PM EDT
If you need this to be in C# code, then do you need for there to be a value associated each name? For example, do you need both a property name and a property value?
Perhaps you need to use a C# array or a List or ArrayList or Dictionary or some other collection.