Question Accessing to XML data

PL_Andrev

New member
Joined
Oct 9, 2016
Messages
2
Programming Experience
Beginner
Hi all,

To want to take a data from XML file and I'm using this structure:

XML file:
<root>
<Row_1><Data>...</Data></Row_1>
<Row_2><Data>...</Data></Row_2>
</root>

Dim xml = XDocument.Load(path)
Dim a
a = xml.<root>.<Row_1>.<Data>.Value

Now is the question - how to declare <Row_1> as a variable to add conditions to set correct row from XML should be read as a example below?

b = <Row_1>
Dim a = xml.<root>.b.<Name>.Value
 
that/those elements as variable:
Dim b = xml.<root>.<Row_1>
Dim c = b.<Data>.Value

or if you mean a string variable with name of node:
Dim variable = "Row_1"
Dim a = xml.<root>.Elements(variable).<Name>.Value

you said:
Don't do this, it will declare a as type Object instead of inferring the type of assigned value/object.
 
Back
Top