Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# loop xml

XmlReader reader = XmlReader.Create(new System.IO.StringReader(settings));
while (reader.Read())
{
    // Note! This does loop all the ways through your xml (even child nodes)
    if (reader.NodeType == XmlNodeType.Element)
    {
		// additionally you can see switch between the nodes.
       //<parent test="asd"><child /></parent>
		switch (reader.LocalName)
        {
          case "parent":
			// Here you can access the attributes
            for (int i = 0; i < reader.AttributeCount; i++)
            {
                reader.MoveToAttribute(i);   // i = 1
                string name = reader.Name; 	 // test
				string value = reader.Value; // asd
            }
            break;

          case "child":
            break;
        }
    }
}
Comment

c# loop xml


  string xml = @"
    <parent>
      <child>
        <nested />
      </child>
      <child>
        <other>
        </other>
      </child>
    </parent>
    ";

  XmlReader rdr = XmlReader.Create(new System.IO.StringReader(xml));
  while (rdr.Read())
  {
    if (rdr.NodeType == XmlNodeType.Element)
    {
      Console.WriteLine(rdr.LocalName);
    }
  }

Comment

PREVIOUS NEXT
Code Example
Csharp :: unity game object remove parent 
Csharp :: assembly project name c# .net 
Csharp :: compact in laravrl 
Csharp :: what value of combobox index c# 
Csharp :: wasd code for unity 
Csharp :: unity vector3 to array 
Csharp :: how to store some variables on the device in unity 
Csharp :: run file windows forms 
Csharp :: Plugging a Third-Party IoC Container (e.g. AutoFac) into .NET Core 6 
Csharp :: C# round number of digits after decimal point 
Csharp :: c# timer 30 seconds 
Csharp :: to list c# 
Csharp :: get enum value c# 
Csharp :: static class can have non static member in c# 
Csharp :: get device name c# console 
Csharp :: c# get distinct values all fields from list 
Csharp :: enable cors asp.net mvc 
Csharp :: c# sftp 
Csharp :: mysqldump - date 
Csharp :: unity soft body 
Csharp :: change size of button c# 
Csharp :: unity dotween sequence 
Csharp :: ultimate space cruiser 
Csharp :: how to sign in with your unity id in unity hub 
Csharp :: unity c# find object position in array 
Csharp :: c# caractère cacher mot de passe 
Csharp :: c# list keyvaluepair update value 
Csharp :: cdn providers 
Csharp :: c# calculate checksum of file 
Csharp :: pick random point inside box collider unity 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =