简体   繁体   中英

Reading complex XML file in c#

I have a XML file and I want to read it and show some part of my xml in a list:

<collection>
<source/> 
<date/>
<key/>
<document>
  <id>AIMed_d30</id> 
    <passage> 
      <offset>0</offset> 
      <text>Isolation of human delta-catenin and its binding specificity with presenilin 1. We screened proteins for interaction with presenilin (PS) 1, and cloned the full-length cDNA of human delta-catenin. </text>
      <annotation id="T1"> 
        <infon key="file">ann</infon> 
        <infon key="type">protein</infon> 
        <location length="13" offset="19"/> 
        <text>delta-catenin</text>
      </annotation>
      <relation id="R4">
        <infon key="relation type">Interaction</infon> 
        <infon key="file">ann</infon> 
        <infon key="type">Relation</infon> 
        <node role="Arg1" refid="T12"/> 
        <node role="Arg2" refid="T13"/> 
      </relation>
     </passage>
  </document>

at first I want to read whole xml file and then i want to show the part:"collection/document/id/passage/annotation/text" and save the other part in strings. I search the net and stackoverflow, but it doesn't help me and didn't get the answer I want.

I will really appreciate if you help me.

You can use the XmlDocument Class to read and save the XML document. It's in System.Xml .

Read more about it here:

https://msdn.microsoft.com/en-us/library/system.xml.xmldocument%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM