Skip to content

Latest commit

 

History

History
56 lines (43 loc) · 1.09 KB

README.md

File metadata and controls

56 lines (43 loc) · 1.09 KB

XmlLit

XmlLit is super light xml parser for .NET

Build status

This library has used XmlReader, doesn't have used linq.

Usage

<?xml version='1.0' encoding='utf-8'?>
<data>
  <Row>
    <uid>1</uid>
    <id>A001</id>
    <enable>True</enable>
  </Row>
  <Row>
    <uid>2</uid>
    <id>A002</id>
    <enable>True</enable>
  </Row>
</data>
class Row {
  public int uid;
  public string id;
  public bool enable;
}

List<Row> rows = new List<Row>();

XmlReader reader = XmlReader.Create(text_reader);
Node.Load(reader, delegate (Node element) {
  Row row = new Row();
  row.uid = int.Parse(element["uid"].Value);
  row.id = element["id"].Value;
  row.enable = bool.Parse(element["enable"].Value);
  rows.Add(row);
}, "data/Row");

Parse

XmlLit.Node.Load(stream, delegate (Node), target_path);

Get elements and attributes.

element["some_element_name"]

element["@some_attribute_name"]

Access all elements and all attributes

element.Children