XML Reading

T

thomson

Hi all,
I do have an XML file which i have given below, AS you can
see there is an id attribute with the master element , If i pass the id
for eg: 1 i need to get all the field elements associated with it,
Can any one let me know how best we can traverse it and
return the values



<MasterConf>
<Master id="1" Name="Country">
<Table>ADM_COUNTRY_MST</Table>
<field>Country_Code</field>
<field>User_TCode</field>
<Primary>Country_TCode</Primary>
</Master>
<master id="2" Name="City">
-

</MAsterConf>


Thanks in Advance

thomson
 
T

Terry Olsen

Here's a routine I use in one of my apps.

Dim sr As New StringReader(rcvd.Msg)
Dim xmlReader As New XmlTextReader(sr)
With xmlReader
..WhitespaceHandling = WhitespaceHandling.None
Dim Cont As Boolean = .Read
While Cont
If .IsStartElement Then
Select Case .Name
Case "Master"
..MoveToAttribute("id")
Dim IDValue as String/Integer = .Value
'--Do Something here depending on your IDValue
Case "SomeOtherElementName"
'--Do whatever...
End Select
End If
Cont = .Read
End While
..Close()
End With
sr.close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top