Accepted answer
  • use xdocument.parse() to create a document supporting xml declaration
  • to get units, use

    xdocument.parse("...").root // or element("email")
  • or use xpath: email/meta/smartform/unit

  • also you can use query-style:

    var doc = xdocument.parse("...");
    var q = from meta in doc.root.elements("meta")
            from smartform in meta.elements("smartform")
            from unit in smartform.elements("unit")
            select unit;


for #1:

xelement doc = xelement.load(file);
xelement valueelement = doc.element("value");
string value = (string)valueelement;


the following works for me:

var xd = xdocument.load("test.xml");
var xv = xdocument.parse((string)xd.root.element("value"));

output is 2, for forgotpassword and forgotusername.

Related Query

More Query from same tag