Link to home
Start Free TrialLog in
Avatar of Tom Sage
Tom SageFlag for United States of America

asked on

XML and Linq - reading fields in repeating nodes

Hello, I have an XML with repeating nodes that I am trying to read with Linq.  Here is sample XML

<Tax>
   <TaxType>Monthly Use</TaxType>
   <TaxDescription>Monthly Use</TaxDescription>
   <TaxAmount>34.01</TaxAmount>
   <TaxRate>9.00000</TaxRate>

</Tax>
<Tax>
   <TaxType>CapCostReduction</TaxType>
   <TaxDescription>CapCostReduction</TaxDescription>
   <TaxAmount>128.83</TaxAmount>
   <TaxRate>5.00000</TaxRate>
</Tax>

Open in new window

Here is my Linq code so far.
 Dim doc As XDocument = XDocument.Load(inFile)

            Dim taxSegs As IEnumerable(Of String) = 
                From seg In doc...<Tax>
                Select desc = seg...<Tax>.Where(Fuction(x) x.Name = "TaxDescription").Value

Open in new window


Thanks for any help
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

And your question is?
Avatar of Tom Sage

ASKER

Sorry it was not clear - I am getting an error with the LINQ query above.

On the x.Name, the x is underlined with this message:  Comma, ')', or valid expression continuation expected.
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial