Click here to Skip to main content
15,902,198 members
Home / Discussions / C#
   

C#

 
GeneralRe: problem in applying grid style to datagrid Pin
Heath Stewart11-Jun-04 4:14
protectorHeath Stewart11-Jun-04 4:14 
GeneralReadin XML Attributes Pin
saud_a_k11-Jun-04 1:14
saud_a_k11-Jun-04 1:14 
GeneralRe: Readin XML Attributes Pin
Alex Getman11-Jun-04 2:45
Alex Getman11-Jun-04 2:45 
GeneralRe: Readin XML Attributes Pin
saud_a_k11-Jun-04 3:00
saud_a_k11-Jun-04 3:00 
GeneralRe: Readin XML Attributes Pin
Heath Stewart11-Jun-04 4:10
protectorHeath Stewart11-Jun-04 4:10 
GeneralRe: Readin XML Attributes Pin
saud_a_k13-Jun-04 20:55
saud_a_k13-Jun-04 20:55 
GeneralRe: Readin XML Attributes Pin
Heath Stewart14-Jun-04 3:40
protectorHeath Stewart14-Jun-04 3:40 
GeneralRe: Readin XML Attributes Pin
saud_a_k14-Jun-04 17:58
saud_a_k14-Jun-04 17:58 
I got this code on the net....


private void AddWithChildren(XmlNode xnod, Int32 intLevel)
{
//Adds a node to the ListBox, togather with its children.
//intLevel controls the depth of indenting
XmlNode xnodWorking;
String strIndent = new string(' ',2 * intLevel);
//Get the value of the node (if any)
string strValue = (string) xnod.Value;
if(strValue != null)
{
strValue = " : " + strValue;
}
//Add the node details to the ListBox
Console.WriteLine(strIndent + xnod.Name + strValue);

//For an element node, retrive the attributes
if (xnod.NodeType == XmlNodeType.Element)
{
XmlNamedNodeMap mapAttributes = xnod.Attributes;
//Add the attributes to the ListBox
foreach(XmlNode xnodAttribute in mapAttributes)
{
Console.WriteLine(strIndent + " " + xnodAttribute.Name +
" : " + xnodAttribute.Value);
}
//If there are any child node, call this procedrue recursively
if(xnod.HasChildNodes)
{
xnodWorking = xnod.FirstChild;
while (xnodWorking != null)
{
AddWithChildren(xnodWorking, intLevel +1);
xnodWorking = xnodWorking.NextSibling;
}
}
}
It workes fine but I thought it would be a little easier to get the attributes.. mainly those which are present in the same line as the element tag like
<person fname=nnn lname=hhh>
.....
</person>
Is there an easier way...

MaXx
GeneralRe: Readin XML Attributes Pin
Heath Stewart15-Jun-04 2:30
protectorHeath Stewart15-Jun-04 2:30 
GeneralRe: Readin XML Attributes Pin
saud_a_k15-Jun-04 17:57
saud_a_k15-Jun-04 17:57 
GeneralRe: Readin XML Attributes Pin
Heath Stewart16-Jun-04 3:20
protectorHeath Stewart16-Jun-04 3:20 
GeneralRe: Readin XML Attributes Pin
saud_a_k16-Jun-04 18:49
saud_a_k16-Jun-04 18:49 
GeneralRe: Readin XML Attributes Pin
Heath Stewart16-Jun-04 21:00
protectorHeath Stewart16-Jun-04 21:00 
GeneralRe: Readin XML Attributes Pin
saud_a_k16-Jun-04 21:11
saud_a_k16-Jun-04 21:11 
GeneralRe: Readin XML Attributes Pin
eggie511-Jun-04 12:59
eggie511-Jun-04 12:59 
GeneralRe: Readin XML Attributes Pin
saud_a_k14-Jun-04 18:02
saud_a_k14-Jun-04 18:02 
GeneralFTP Class Pin
SatyaDY11-Jun-04 0:24
SatyaDY11-Jun-04 0:24 
GeneralBeginner Q: Where to get Info on &quot;distributed assemblies&quot; Pin
matthias s.11-Jun-04 0:11
matthias s.11-Jun-04 0:11 
GeneralRe: Beginner Q: Where to get Info on &quot;distributed assemblies&quot; Pin
Colin Angus Mackay11-Jun-04 3:51
Colin Angus Mackay11-Jun-04 3:51 
Questionhooking??? Pin
10-Jun-04 22:32
suss10-Jun-04 22:32 
AnswerRe: hooking??? Pin
Stefan Troschuetz10-Jun-04 23:15
Stefan Troschuetz10-Jun-04 23:15 
AnswerRe: hooking??? Pin
leppie11-Jun-04 7:20
leppie11-Jun-04 7:20 
General.Net Remoting Problem Pin
Member 33502210-Jun-04 22:14
Member 33502210-Jun-04 22:14 
GeneralRe: .Net Remoting Problem Pin
Stefan Troschuetz10-Jun-04 22:52
Stefan Troschuetz10-Jun-04 22:52 
GeneralRe: .Net Remoting Problem Pin
Heath Stewart11-Jun-04 4:07
protectorHeath Stewart11-Jun-04 4:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.