Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reading only a specific portion of XML file.

0 views
Skip to first unread message

Savvoulidis Iordanis

unread,
Dec 14, 2009, 4:59:01 PM12/14/09
to
I created the following test XML file, containing the translations of all my
reports's labels in all available languages. Every report has all its
localized texts under the proper CultureID node, under the report's name. The
question is, (as I'm new to XML/XPath/etc...) using ASP.NET(VB), how to read
all the labels of a report in a specified language, into a dataset? Imagine
that for a report (e.g. Report_A) the user selects the CultureID from a
dropdown list, to display the proper translations.


<?xml version="1.0" encoding="utf-8" ?>
<ReportTranslations>
<Report_A>
<el-GR>
<Control Name="lbl_1" Text="AAA" FormatString=""/>
<Control Name="lbl_2" Text="BBB" FormatString=""/>
<Control Name="lbl_3" Text="ΓΓΓ" FormatString=""/>
</el-GR>
<en-US>
<Control Name="lbl_1" Text="AAA" FormatString=""/>
<Control Name="lbl_2" Text="BBB" FormatString=""/>
<Control Name="lbl_3" Text="CCC" FormatString=""/>
</en-US>
</Report_A>

<Report_B>
<el-GR>
<Control Name="lbl_4" Text="ΔΔΔ" FormatString=""/>
<Control Name="lbl_5" Text="ΕΕΕ" FormatString=""/>
<Control Name="lbl_6" Text="ΖΖΖ" FormatString=""/>
</el-GR>
<en-US>
<Control Name="lbl_4" Text="DDD" FormatString=""/>
<Control Name="lbl_5" Text="EEE" FormatString=""/>
<Control Name="lbl_6" Text="FFF" FormatString=""/>
</en-US>
</Report_B>

</ReportTranslations>

Alexey Smirnov

unread,
Dec 15, 2009, 3:50:41 AM12/15/09
to
On Dec 14, 10:59 pm, Savvoulidis Iordanis

Dim ds As New DataSet()
Dim xDoc As New XmlDocument()

'Load the contents of the file to our XmlDocument object
xDoc.LoadXml(File.ReadAllText(Request.PhysicalApplicationPath &
"XMLFile1.xml"))

'Select XML Node you need (e.g. for Report_A/el-GR)
Dim xn As XmlNode = xDoc.SelectSingleNode("//ReportTranslations/
Report_A/el-GR")

'Load the xml data in the XmlDocument object to the Dataset
ds.ReadXml(New XmlNodeReader(xn))

Savvoulidis Iordanis

unread,
Dec 15, 2009, 10:11:03 AM12/15/09
to
Thanks Alexey. It worked!

I noticed that up to date, you've answered a lot of my posts. Thanks!

Iordanis
Greece

Alexey Smirnov

unread,
Dec 15, 2009, 4:18:11 PM12/15/09
to
On Dec 15, 4:11 pm, Savvoulidis Iordanis

:-)

0 new messages