Question Read an XML File

molemenacer

Active member
Joined
Jul 27, 2006
Messages
27
Location
Haywards Heath, UK
Programming Experience
Beginner
Hi all,

I am using VS2008 and am trying to read an xml file

This is the xml file i am trying to read

VB.NET:
- <SJA JobNo="4311" SurveyDate="19-Apr-2007 12:49" Weather="clear, dry and bright" Surveyor="Luke Dawson" Site="" SurveyType="DevTS" HandS="HS110=7/HS111=1/HS112=site officie/HS201=1/HS202=1/HS203=0/HS204=1/HS205=1/HS206=0/HS207=0/HS208=1/HS209=0/HS210=0/HS211=0/HS212=0/HS301=0/HS303=1/HS302=0/HS304=0/HS305=0/HS306=0/HS307=0/HS400=0/HS401=0/HS402=0/HS403=0/HS404=0/HS405=0/HS406=0/HS407=0/" Leaf="Partial" Photos="Indeterminate" Agent="Indeterminate" Operatives="Indeterminate" Halted="Indeterminate" NextVisit="26-Apr-07">
- <Section Name="4311">
  <Tree No="29" TPO="" Tag="" Species="6" Height="" Trunk="" RCS="=/E=3.75" CH="=/E=3" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="" Rec="" Cat="" Plt="0" Loc="pro fen//4.55//E/" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="30" TPO="" Tag="" Species="6" Height="" Trunk="" RCS="=/E=4.5" CH="=/E=0.5" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//4.75//E/" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="31" TPO="" Tag="" Species="6" Height="" Trunk="" RCS="=/E=4.75" CH="=/E=0.5" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//4.95//E/" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="32" TPO="" Tag="" Species="6" Height="" Trunk="" RCS="=/E=5.25" CH="=/E=0.25" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//4.75///" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="33" TPO="" Tag="" Species="37" Height="" Trunk="" RCS="=/E=3.75" CH="=/E=0" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//4.25///" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="34" TPO="" Tag="" Species="6" Height="" Trunk="" RCS="=/E=5.5" CH="=/E=0.5" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//4.2///" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="35" TPO="" Tag="" Species="6" Height="" Trunk="" RCS="=/E=4.5" CH="=/E=0.5" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//4.25///" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="36" TPO="" Tag="" Species="6" Height="" Trunk="" RCS="=/E=4.5" CH="=/E=0.5" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//4.5///" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="37" TPO="" Tag="" Species="6" Height="" Trunk="" RCS="=/E=4.9" CH="=/E=0.5" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//4.9///" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="38" TPO="" Tag="" Species="6" Height="" Trunk="255@1.5m#38" RCS="=/E=4.25" CH="=/E=0" Age="" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//5.2///" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  <Tree No="39" TPO="" Tag="" Species="6" Height="" Trunk="480@1.5m#39" RCS="=/E=5.25" CH="=/E=0" Age="S" Phy="Av" Str="" Frm="" Pot="" Vis="" Com="On Dictaphone" Rec="" Cat="" Plt="0" Loc="pro fen//4.9///" Qty="" Val="" RR1="//" RR2="//" RR3="//" /> 
  </Section>
  </SJA>

I can load the xml file into an xml document, but what i am struggling with is how to go through each <TREE> tag in the <SECTION> node and get out some of the information.

Does anyone have any ideas, thanks in advance.
 
I spend ages looking for an answer and can't find anything, post a question and suddenly i find the answer.

What i have done is loaded the xml file into an xmldocument, then specifying the node to start at and then iterating over all the nodes in that list.
 
Back
Top