Click here to Skip to main content
16,004,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an xml, how to get the output of a tag using LINQ.

HTML
<xtr:errorcode xmlns:xtr="http://ssrs-l/schemas/Port">0</xtr:errorcode>
  <xtr:errortext xmlns:xtr="http://ssrs-l/schemas/Por" />
  <xtr:orderid xmlns:xtr="http://ssrs-l/schemas/Por">1192232804</xtr:orderid>
  <assignmentinformation xmlns="http://ssrs-l/schemas/Po">
    <order>
<orderheader>
<some tags="">
</some></orderheader>

<service>
<some tags="">
</some></service>

<ports>

<port>
          
          <node>
            <id>252689529</id>
           
               <node>
              <id>252691056</id>
              <systembay>01</systembay>
              <brick>
                <id>2</id>
                <name>Stinger (CR)</name>
                <number>011</number>
                <logicalnumber />
              </brick>
              <tat>
                <id>2</id>
                <name>02</name>
           <number>02</number>
                <zone>0</zone>
              </tat>
             
            </node>
          </node>
          <relation>
            <port>
              <bindingpostnumber>2587</bindingpostnumber>
              
              <node>
                <name>0</name>
                <type>Te</type>
                <connection>B</connection>
              </node>
            </port>

           <port>
              <binding>1</binding>
              <bindingpost> Post In</bindingpost>
              <node>
                <name>00</name>
                <type>Ter</type>
                <connectiontype>B</connectiontype>
              </node>
            </port>
          </relation>
        </port>



        <port>
           
          <node>
            <id>252689529</id>
           
               <node>
              <id>252691056</id>
              <systembay>01</systembay>
              <brick>
                <id>2</id>
                <name>Stinger (CR)</name>
                <number>012</number>
                <logicalnumber />
              </brick>
              <tat>
                <id>2</id>
                <name>02</name>
                <number>022</number>
                <zone>0</zone>
              </tat>
             
            </node>
          </node>
          <relation>
            <port>
              <bindingpostnumber>2587</bindingpostnumber>
              
              <node>
                <name>0</name>
                <type>Te</type>
                <connection>B</connection>
              </node>
            </port>

           <port>
              <binding>1</binding>
              <bindingpost> Post In</bindingpost>
              <node>
                <name>00</name>
                <type>Ter</type>
                <connectiontype>B</connectiontype>
              </node>
            </port>
          </relation>
        </port>

       
</ports>
</order>
</assignmentinformation>



The bold one is my out put.


Regards,
S.Inaayt Basha.
Posted
Updated 24-Nov-11 22:28pm
v4

1 solution

Refer this link to fetch the data using LINQ.
Get the Value from a Node, LINQ to XML[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900