<Connections>
<Connection ID = "1" Source="1:0" Sink="4:0"/>
<Connection ID = "2" Source="2:0" Sink="4:1"/>
<Connection ID = "3" Source="2:0" Sink="5:0"/>
<Connection ID = "4" Source="3:0" Sink="5:1"/>
<Connection ID = "5" Source="4:0" Sink="6:0"/>
<Connection ID = "6" Source="5:0" Sink="7:0"/>
</Connections>
When I need to get information from the previous XML code, Python lxml can be used as follows.
def getNodeList(self):
connection = self.doc.find('Connections')
cons = connection.find('Connection')
for con in cons.iter():
con.get("ID")
...
- What C # libraries / functions can I use to get information like python lxml? I mean, can I use find () / iter () or similar with C #?
- What C # libraries look like lythml python?
ADDED
Based on the dtb answer, I could get what I need.
using System;
using System.Xml;
using System.Xml.Linq;
namespace HIR {
class Dummy {
static void Main(String[] argv) {
XDocument doc = XDocument.Load("test2.xml");
var connection = doc.Descendants("Connections");
var cons = connection.Elements("Connection");
foreach (var con in cons)
{
var id = (string)con.Attribute("ID");
Console.WriteLine(id);
}
}
}
}
I had to remove "First ()" to avoid a compiler error. With mono, I can run the following to get the binary.
dmcs /r:System.Xml.Linq main.cs
source
share