Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!


SimpleXml is simple dynamic xml parsing.

Install with NuGet: install-package SimpleXml

Read and Write Xml:

var x =
  @"<root attr="attrvalue">

x.root.child == "nodevalue"
x.root.attr == "attrvalue"

x.root.child = "newnodevalue";
x.root.attr = "newattrvalue";

Read and Write Multiple Nodes:

var x =

x.root.node == IEnumerable containing "value1" and "value2"
x.root.node = "new value"

Read and Write Multiple Nodes With Child Nodes:

var x =

x.root.node.child == IEnumerable containing "value1" and "value2"
x.root.node.child = "new value"

Selecting Nodes By Attribute Value:

var x =
      <node name="a">value1</node>
      <node name="b">value2</node>
      <node name="c">value3</node>

x.root.node.First("name", "b") == "value2"
x.root.node.FirstOrDefault("name", "b") == "value2"
x.root.node.Where("name", "b") == IEnumerable containing "value2"

Selecting Nodes By Attribute Value With Child Nodes:

var x =
      <node name="a"><child>value1</child></node>
      <node name="b"><child>value2</child></node>
      <node name="c"><child>value3</child></node>

x.root.node.First("name", "b").child == "value2"
x.root.node.FirstOrDefault("name", "b").child == "value2"
x.root.node.Where("name", "b").child == "value2"

Load From File:

var stream = File.Open("path\to\file", FileMode.Open);
dynamic x = new SimpleXml(stream);

Save To File:

var stream = File.Open("path\to\file", FileMode.Create);

Ignores Namespaces:

var x =
  @"<root xmlns="" xmlns:t="">

x.root.child == "value"

Special Case For Leaf Nodes With Attributes:

var x =
      <child attr="attrvalue">childvalue</child>

x.root.child.text == "childvalue"
x.root.child.attr == "attrvalue"

Written by Kevin Berridge

Licensed under the MIT License

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.