0

I have a xml file with data as follows

   <P1 type="CP" name="E01+W">
    <DNo>4423</DNo>
    <CNo>abc</CNo>
  </P1>

    <P2 type="DP" name="E02+W">
    <DNo>5623</DNo>
    <CNo>xyz</CNo>
  </P2>

How to I get Attribute value type="CP" and "DP" of P1 and P2 node in one column. More like Traverse to each node of and its sub node and get each subnode type attribute value in one column.

Type   Name
CP     EO1
DP     EO2

1 Answer 1

1

You can use XDocument

var xml = XDocument.Parse([string]);
xml.Elements().Select( x => new { Type = x.Attribute("type").Value, 
                                  Name =  .Attribute("Name").Value});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.