ValoChele

ValoChele

  • NA
  • 68
  • 21k

How to get the contents between two same nodes?

Mar 8 2018 9:23 AM
How do I get the contents between two nodes (under the same parent node) as a string...for example, assume there is a xml file as
  1. <xml version="1.0"?>  
  2. <main>  
  3.     <abc>This is <day>1day> the <day>5day>th <month>Novembermonth> <year>1993year><abc>  
  4.     <xyz>It does not matter what <day>10day> it is <day>3day> of <day>19day><xyz>  
  5. <main>  
How do I get the contents between the first node and the next node under a any given parent  nodes?. i.e. the output should give the results
" the ",  " it is " and " of ".
 I think it's gonna look something similar to
 
var nodes = Doc.DescendantNodes().OfType<XText>().Select(a=>a.Value) 
but I cannot figure exactly how?
Can someone help...? 
 

Answers (3)