Querying internal elements using LINQ to XML

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,

I am trying to use XML file for dumping some data into Excel file from database. I need to get the parameters list as well.

Tried this but cannot access more than one parameter.

Request your kind help

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; var q = <span style="color:Blue; from c <span style="color:Blue; in xd.Descendants(<span style="color:#A31515; "Data")
<span style="color:Blue; select <span style="color:Blue; new
{Sheet = c.Element(<span style="color:#A31515; "Sheet").Value,
Range = c.Element(<span style="color:#A31515; "Range").Value,
StoredProc = c.Element(<span style="color:#A31515; "StoredProcedure").Value,
<span style="color:Green; //ParamArray = c.Element("Parameters").Value,
Number = c.Element(<span style="color:#A31515; "Parameters").Element(<span style="color:#A31515; "Number").Value,
ParamName = c.Element(<span style="color:#A31515; "Parameters").Element(<span style="color:#A31515; "ParameterName").Attribute(<span style="color:#A31515; "Name").Value
};
[/code]


<Data ToLoad = "CRD

<Sheet>Suppsed</Sheet>

<Range>rangesin</Range>

<StoredProcedure>storedproc</StoredProcedure>

<Parameters>

<Number>3</Number> // Provides number of parameters (comment only here not in XML file)

<ParameterName Name="@param1"/>

<ParameterName Name ="@param2"/>

<ParameterName Name ="@param3" />

</Parameters>

</Data>



View the full article
 
Back
Top