-2

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.

leppie
  • 115,091
  • 17
  • 196
  • 297
Nooshin T
  • 1
  • 3
  • 3
    Your XML doesn't look well-formed. There is no closing tag, and also the tag is not a child of the tag so there isn't a path from to to make your "/id/passage" xpath work. – PhillipH Apr 22 '16 at 19:40
  • _"and save the other part in strings"_ is not very clear. – H H Apr 22 '16 at 19:53
  • 1
    `but it doesn't help me and didn't get the answer I want` What kind of answers did you find? and what kind of answers do you want? The reason I ask is because If I were to answer your question, I'd give you the same kind linq-to-xml based answer that I've posted here before, but I'm not certain that It'll meet your needs. – Sam I am says Reinstate Monica Apr 22 '16 at 19:54
  • Look up Linq to Xml, XmlSerializer, XmlDocument, and XPath, then come back with a better question after you've tinkered a bit. It's not especially clear what you want from this. – maniak1982 Apr 22 '16 at 20:25
  • Yes, you are all right. In annotation tag, i have a child tag which name is . and shows a word. I want to show all texts in this tag in a listview. and also, I need the data of relation tag which name is node: " " . and want to store them some where (not sure to save them in RAM or a DB... I know differences ofcourse) – Nooshin T Apr 23 '16 at 08:13

1 Answers1

0

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

Poul Bak
  • 10,450
  • 5
  • 32
  • 57