i think that you are a little bit confused
Xdocument xdoc=Xdocument.Load(filepath);
that's all you need that you can move withn xml without any issue in example
xdoc.root.elements("nameElement").Attributes("nameAttribute").Value
and so on.
it's really simple :)
here a simple example : in vbnet and then in c#. Assume that you have a simple webpage with a button with its event
Protected Sub btnGetValues_Click(sender As Object, e As EventArgs) Handles btnGetValues.Click
Dim xdoc As XDocument = XDocument.Load(Server.MapPath("~/data.xml"))
Dim ns As XNamespace = "http://winscp.net/schema/session/1.0"
Dim Sb As New StringBuilder
Try
'iterate within xmlelement where assume with this code that "session" is root
'and descendant are upload and its child and touch with its childs
For Each el In (From a In xdoc.Root.Descendants(ns + "upload") Select a)
For Each subelement In el.Descendants
Response.Write("<b>" & subelement.Name.ToString & "</b><ul>")
If subelement.HasAttributes Then
For Each att In subelement.Attributes
Response.Write("<li>" & att.Name.ToString & ":" & att.Value.ToString & "</li>")
Next
End If
Response.Write("</ul>")
Next
Next
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
C# Version:
protected void btnGetValues_Click(object sender, EventArgs e)
{
XDocument xdoc = XDocument.Load(Server.MapPath("~/data.xml"));
XNamespace ns = "http://winscp.net/schema/session/1.0";
StringBuilder Sb = new StringBuilder();
try {
//iterate within xmlelement where assume with this code that "session" is root
//and descendant are upload and its child and touch with its childs
foreach (object el_loopVariable in (from a in xdoc.Root.Descendants(ns + "upload")a)) {
el = el_loopVariable;
foreach (object subelement_loopVariable in el.Descendants) {
subelement = subelement_loopVariable;
Response.Write("<b>" + subelement.Name.ToString + "</b><ul>");
if (subelement.HasAttributes) {
foreach (object att_loopVariable in subelement.Attributes) {
att = att_loopVariable;
Response.Write("<li>" + att.Name.ToString + ":" + att.Value.ToString + "</li>");
}
}
Response.Write("</ul>");
}
}
} catch (Exception ex) {
Response.Write(ex.Message);
}
}
This is result in page as response.write:
{http://winscp.net/schema/session/1.0}filename
{http://winscp.net/schema/session/1.0}destination{http://winscp.net/schema/session/1.0}result