following sample uses XmlTextReader to read from XML file
XmlTextReader reader = new XmlTextReader(MapPath("~/XML/States.xml"));
while (reader.Read())
{ switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
Console.Write("<" + reader.Name);
while (reader.MoveToNextAttribute()) // Read the attributes.
Console.Write(" " + reader.Name + "='" + reader.Value + "'");
Console.WriteLine(">");break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine (reader.Value);
break;
case XmlNodeType. EndElement: //Display the end of the element.
Console.Write("</" + reader.Name);
Console.WriteLine(">");
break;
}
//sample XML file
<?xml version="1.0" encoding="utf-8" ?>
<Items> <Item ddlValue ="1" ddlText = "Yes" />
<Item ddlValue ="2" ddlText = "No" />
</Items>
Subscribe to:
Post Comments (Atom)
If you’re using Visual Studio to build your .NET MAUI app on a Mac, locating the IPA (iOS App Package) file can be a bit tricky
If you’re using Visual Studio to build your .NET MAUI app on a Mac , locating the IPA (iOS App Package) file can be a bit tr...
-
Grid is a layout panel that consists of rows and columns. Example 1: < Grid > < Grid.RowDefinitions > < Row...
-
Label tb = new Label (); tb.Name = "LabelID" + iRow; tb.Content = lblName; Grid .SetColumn(tb, iCol); Grid .SetRow(tb,...
-
HttpClient is a .NET class that an app can use to send HTTP requests and receive HTTP responses from a REST web service. The resources that...
No comments:
Post a Comment