Skip to content

Commit

Permalink
xml record traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
nahiandev committed Dec 9, 2024
1 parent ef25cf1 commit 2cd2dee
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
41 changes: 39 additions & 2 deletions DomeTrain/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
using System.Runtime.CompilerServices;
using System.Xml;

namespace DomeTrain
{
class Program
{
static void Main()
{
var text = "Hello World!";
//string xml_records = """
// <?xml version="1.0" encoding="UTF-8"?>
// <people>
// <person>
// <name>John Doe</name>
// <age>30</age>
// </person>
// <person>
// <name>Jane Smith</name>
// <age>25</age>
// </person>
// <person>
// <name>Bob Johnson</name>
// <age>40</age>
// </person>
// </people>
// """;

string filename = "people.xml";



//File.WriteAllText(filename, xml_records);

XmlDocument doc = new();
doc.Load(filename);


XmlNodeList people = doc.SelectNodes("/people/person")!;


foreach(XmlNode node in people)
{
Console.WriteLine(node["name"]!.InnerText);
Console.WriteLine(node["age"]!.InnerText);
Console.WriteLine("---------------------");
}


Console.WriteLine(text.GetUTF8Bytes());
}
}
}
3 changes: 1 addition & 2 deletions DomeTrain/StringExtention.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using System.Text;
using System.Text;

namespace DomeTrain
{
Expand Down

0 comments on commit 2cd2dee

Please sign in to comment.