EDN Admin
Well-known member
Im trying to parse the following XML:
<reports><br/>
<report name="rptTest1 <br/>
<description>Test Report 1</description><br/>
<reportfolder>default</reportfolder><br/>
<parameters><br/>
<parameter name ="Date From <br/>
<type>DATE</type><br/>
<default>Today</default><br/>
</parameter><br/>
<parameter name ="Date To <br/>
<type>DATE</type><br/>
<default>Today</default><br/>
</parameter><br/>
</parameters><br/>
</report><br/>
<report name="rptTest2 <br/>
...<br/>
</report><br/>
</reports>
I would like to create 1 line for each parameter element which includes the report description, the reason being I am loading this into a datagridview:
Test Report 1~Date From~DATE~Today
Test Report 1~Date To~DATE~Today
Test Report 2~ ......
So far my code reads as follows (VS2008 Windows Form App):
Dim myXML as XElement = XElement.Load(fpath)<br/>
Dim result = From st In myXML.Descendants("parameter") _<br/>
Select New With {.rptdesc = st.Parent.<description>.Value, _<br/>
.parmval = st.<type>.Value}
The st.Parent doesnt return a value, Im thinking its because the <description> is up 2 levels. I would appreciate help with this one as Im relatively new to this method of parsing an XML file. Would it be better to get rid of the
<Parameters> tag?
Thanks.
View the full article
<reports><br/>
<report name="rptTest1 <br/>
<description>Test Report 1</description><br/>
<reportfolder>default</reportfolder><br/>
<parameters><br/>
<parameter name ="Date From <br/>
<type>DATE</type><br/>
<default>Today</default><br/>
</parameter><br/>
<parameter name ="Date To <br/>
<type>DATE</type><br/>
<default>Today</default><br/>
</parameter><br/>
</parameters><br/>
</report><br/>
<report name="rptTest2 <br/>
...<br/>
</report><br/>
</reports>
I would like to create 1 line for each parameter element which includes the report description, the reason being I am loading this into a datagridview:
Test Report 1~Date From~DATE~Today
Test Report 1~Date To~DATE~Today
Test Report 2~ ......
So far my code reads as follows (VS2008 Windows Form App):
Dim myXML as XElement = XElement.Load(fpath)<br/>
Dim result = From st In myXML.Descendants("parameter") _<br/>
Select New With {.rptdesc = st.Parent.<description>.Value, _<br/>
.parmval = st.<type>.Value}
The st.Parent doesnt return a value, Im thinking its because the <description> is up 2 levels. I would appreciate help with this one as Im relatively new to this method of parsing an XML file. Would it be better to get rid of the
<Parameters> tag?
Thanks.
View the full article