Reading only a specific portion of XML file.

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>

0
Utf
12/14/2009 9:59:01 PM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

3 Replies
602 Views

Similar Articles

[PageSpeed] 17

On Dec 14, 10:59=C2=A0pm, Savvoulidis Iordanis
<SavvoulidisIorda...@discussions.microsoft.com> wrote:
> 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 r=
ead
> all the labels of a report in a specified language, into a dataset? Imagi=
ne
> that for a report (e.g. Report_A) the user selects the CultureID from a
> dropdown list, to display the proper translations.
>
> <?xml version=3D"1.0" encoding=3D"utf-8" ?>
> <ReportTranslations>
> =C2=A0 =C2=A0 <Report_A>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 <el-GR>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_1" Text=3D=
"AAA" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_2" Text=3D=
"BBB" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_3" Text=3D=
"=CE=93=CE=93=CE=93" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 </el-GR>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 <en-US>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_1" Text=3D=
"AAA" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_2" Text=3D=
"BBB" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_3" Text=3D=
"CCC" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 </en-US>
> =C2=A0 =C2=A0 </Report_A>
>
> =C2=A0 =C2=A0 <Report_B>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 <el-GR>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_4" Text=3D=
"=CE=94=CE=94=CE=94" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_5" Text=3D=
"=CE=95=CE=95=CE=95" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_6" Text=3D=
"=CE=96=CE=96=CE=96" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 </el-GR>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 <en-US>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_4" Text=3D=
"DDD" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_5" Text=3D=
"EEE" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <Control Name=3D"lbl_6" Text=3D=
"FFF" FormatString=3D""/>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 </en-US>
> =C2=A0 =C2=A0 </Report_B>
>
> </ReportTranslations>

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 =3D xDoc.SelectSingleNode("//ReportTranslations/
Report_A/el-GR")

'Load the xml data in the XmlDocument object to the Dataset
ds.ReadXml(New XmlNodeReader(xn))
0
Alexey
12/15/2009 8:50:41 AM
Thanks Alexey. It worked!

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

Iordanis
Greece
0
Utf
12/15/2009 3:11:03 PM
On Dec 15, 4:11=A0pm, Savvoulidis Iordanis
<SavvoulidisIorda...@discussions.microsoft.com> wrote:
> Thanks Alexey. It worked!
>
> I noticed that up to date, you've answered a lot of my posts. Thanks!
>
> Iordanis
> Greece

:-)
0
Alexey
12/15/2009 9:18:11 PM
Reply:

Similar Artilces:

Excel
Hi ~ I have an Excel 2000 data file that is corrupt and I can't open it with the usual steps (e.g. excel viewer, web file save, linking, etc.) Now, when I try demo versions of some advertised file recovery utilities, they seem to work, but since it's only a demo download, I can't get more than a few lines of the spreadsheet. Retail costs vary for the utilities, around $200-300+. I find it incredible that MICROSOFT does not have a similar FREE utility that can be used to recover data files, but that several 3rd party companies are more than ready to cash in on these situat...

PC .doc file crashes word (Snow leopard)
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel My system is fully up to date - I install all auto-updates. <br><br>I have had no problem with any .doc file from my PC, and I have imported many. <br><br>An A5 portrait flyer .doc with pictures from a PC (received as an e-mail attachment) opens but almost immediately crashes mac word while trying to convert it to 2 A5 &quot;pages&quot; on a 2 column A4 landscape page for lazer print to be guillotined (print 2 pages on one sheet does not work with the snow leopard driver for my HP...

2 same ways of protecting Excel file
In Excel 2007 we can protect workbook using 2 ways: 1. Office button > Save as, choose file format, and then Tools, General options. 2. Office button > Prepare > Encrypt document Does anybody know is there difference between these 2 ways Thanks ...

how does one convert a publisher file into a jpeg or gif file for.
for recipients with older email versions, such as Outlook 2000? I need to convert a multiple page publication, not just the first page. >-----Original Message----- >for recipients with older email versions, such as Outlook 2000? >I need to convert a multiple page publication, not just the first page. >. > Your question is puzzling. First you are rambling about convert "publisher file into a jpeg." If you are using Publisher 2003, choose Save as from the File drop down menu and in Save as type box, scroll down to JPEG File Interchange Format (* .jpg). I have no ide...

Opening file error
One of my users does work at home (Excel 2000), the puts the work on a diskette and brings it to work (Excel 2000). She she tries to open the file she gets message "document.xls cannot be accessed. The file may be read-only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding. I had her email the document to work to eliminate the possibility of a corrupt diskette. She still could not open it. Does anyone know the problem lies in the scenario? Thanks Kim I saw a similar problem not long ago where I found that...

Distributing XML
I'm using Visual C++ 6.0, but since there doesn't seem to be a vc.xml newsgroup I was hoping someone here would know my question. Does anyone know what exactly I need to do to distribute .xml with an application? Originally I would just include all the xml.dll 's and the .ini file in my application directory and I created a .bat file to run regsrv32.exe on the msxml4.dll. A person on Win98 is having an issue where the xml script is not working and I went back to the microsoft site and noticed there is a sp2 there now. In the release notes it talks about running a .msm file, but...

Read receipts to sender
How do I change the way a read receipt is delivered to the sender to "never send a response" when a message comes through an Internet E-mail Transport. Tools -> Options -> Preferences -> E-mail Options... -> Tracking Options... -- Jeff Stephenson Outlook Development This posting is provided "AS IS" with no warranties, and confers no rights "Ron" <Commander_ron@yahoo.com> wrote in message news:001601c34bac$b8c5ba50$a301280a@phx.gbl... > How do I change the way a read receipt is delivered to the > sender to "never send a response&...

Access an excel file through FTP without write protection
Hi experts I placed a question yesterday - approximately 28 hours ago - nobody have reacted on it - please tell me if you don't understand my question because my English is to bad. thanks jj ...

VBA/Modifier field that will allow you to enter a path to a file
I need to create a new field in GP that will hold the file path to the file. I need to be able to use the browse button to find this path. How can I add this field in either VBA or modifier? thanks Amy Amy, this isn't as easy as you might expect. You don't say whether or not this is a vba form or a GP form. Assuming GP form: 1. use modifier to add a button to the window 2. use modifier to add a field to the window 3. write vba code to call the common dialog to open the lookup window for you (or write your own i guess but why bother?) 4. return the select value back to the st...

Importing an excel.csv file into outlook
I've just set up Outlook to send/receive my yahoo emails. I'm trying to import the contacts and addresses from my yahoo address book. When exporting from yahoo, my address book was saved as an excel file with comma separated values. in order to import it into outlook, i've been getting messages saying the relevant program is not there and i would have to install it or download it. It said something about frontpage, but i'm not sure what i need to do...HELP! ...

Minimilistic XML file for Word
Does anyone know what the least amount of XML information needed to make a Word document? Rather than create a Word document using the Word object model, I would like to create a text file that contains XML tags that Word can interpret as a Word document and fill in the missing information. John... Visio MVP You have to make a package - a single text file doesn't cut it. The minimum is pretty basic - off the top of my head you need a [Content_Types].xml file and a _rels/.rels file, along with the document itself, which needs little more than <document><body&...

csv files into MS Money?
My Smith Barney account downloads as csv files. How does one import these into MS Money? I do not wish to use Passport. Thanks. -- Jeff Stevens Email address deliberately false to avoid spam jeff@stevens.com One converts them to QIF then imports the QIF, more or less. See http://umpmfaq.info/faqdb.php?q=8.. "Jeff" <jeff@phony.com> wrote in message news:%23oI3T$j2EHA.2572@tk2msftngp13.phx.gbl... > My Smith Barney account downloads as csv files. How does one import these > into MS Money? I do not wish to use Passport. ...

files and settings transfer from hard drive to new pc
Is there any way of tranferring the files and settings from a hard drive of which the motherboard has fried to a new pc without having to have to tranfer files individually? The new pc's bios would obviously not be the same as the old pc, so I can't just pop the old HDD into the new one. Both systems are running XP Home. Any help would be appreciated. Thanks Yep, see link first hit http://www.google.com/#hl=en&source=hp&q=moving+hard+drive+to+new+computer+xp&aq=7&aqi=g10&aql=&oq=moving+hard&gs_rfai=Cxsbp-kxATLPLGKX4MbrIia4KAAAAqgQFT9CfZqI&fp=4...

Converting 1999 files into 2004
Hi I have been using Money 1999 for quite some time now and I have just recently brought Money 2004 Standard Edition. I have Installed the 2004 edition and tried to open the 1999 file version. Whenit tries to convert the file it comes with the error message "Money was unable to open this file because it was created with an Incompatible version". Please help! DC An oldie but a goodie. See http://umpmfaq.info/faqdb.php?q=1. "Disgusted user" <anonymous@discussions.microsoft.com> wrote in message news:01e201c49511$36069440$a401280a@phx.gbl... > Hi > &...

merge 2 copies of xml file???
i want to combine data from 2 versions of a music playlist , but can o0nly find help about merging 2 shared workbooks. can't seem to re-set my xml files as shared workbooks. how do i simply merge 2 lists?? -- musicman toronto On Sun, 16 Dec 2007 19:25:01 -0800, musiclover wrote: > i want to combine data from 2 versions of a music playlist , but can > o0nly find help about merging 2 shared workbooks. can't seem to re-set > my xml files as shared workbooks. how do i simply merge 2 lists?? It is not obvious why you'd want to combine two XML files with Excel. Are t...

problem saving xls files into shared folders location
The users in my network are complaining about this problem: They open Excel files from shared folder location and after changes in the file, when trying to save, they get a message sating that the file will be saved under a name something like "E0720002" (different every time). After that the file with the original name disappears from the location, the E0720002 file is there but with no (xls) extension and the users are left without a clue about where the file is -- usually they do not read the message stating that "E0720002" will be the name of the file (I can't blam...

ASX file
I received a message with an attached .asx file. None of the programs I have seems to open it. Please advise what program available for a Mac will open the file. thank you <wgempp@netsense.net> wrote in message news:1109872332.063810.105220@f14g2000cwb.googlegroups.com... > I received a message with an attached .asx file. None of the programs > I have seems to open it. Please advise what program available for a > Mac will open the file. > > thank you > It is a Windows Media file. Depending on the encoding, you can open it with Windows Media Player for the Ma...

No print settings in Excel HTML files
Is there a way to prevent users from printing the HTML files that are created from an Excel workbook ? I see there is html code to do this, but I don't know how to put that into the Excel workbook so that it is always there when the files are updated (which they are frequently). ...

Print Excel file to PDF
Hi, Is there a VBA code, or a program whereby I can print an Excel file to a PDF? (Maybe an add-in?) I'd like to do it directly from Excel similarly to the way Word Perfect has that option in the file menu if possible, but anything will be a help. (I'm using Office 2000) Rob Rob You could purchase Adobe Acrobat. An alternative to buying Adobe Acrobat.... I have had success with the free file downloads and instructions for use here at Dale Nurden's site. http://www.rcis.co.za/dale/info/pdfguide.htm Saves first to single *.ps file which is then converted to *.pdf Return...

Sending files from Vista
Windows mail is my default mail client. But if I right click on a data or picture file from my desktop or other areas it wants to send it with Outlook instead of Windows Mail. What settings do I have to change to get windows mail to do all my mail sending in this manner? "Stumped" <Stumped@discussions.microsoft.com> wrote in message news:4C240124-48D3-4EAB-B63B-8A0B20505905@microsoft.com... > Windows mail is my default mail client. But if I right click on a data or > picture file from my desktop or other areas it wants to send it with > Outlook >...

Need Hyperlinked .jpg file to open in MS Picture Manager
I have created a slide presentation in PP 2007 with a graphic icon on each slide that hyperlinks to a specific .jpg file. The hyper link works great but the .jpg file opens in Windows Internet Explorer, even though I have set MS Office Picture Manager as my default .jpg "open with" program. How can I get my hyperlinked .jpg files to automatically open in MS Office Picture Manager and not in Internet Explorer? In article <AB94855A-C462-47B2-8794-6E5F063EEBE8@microsoft.com>, Triniscuba wrote: > I have created a slide presentation in PP 2007 with a graphic icon o...

Suggest Read only
I have an older doc (xls format) that offers me the message "nameof doc.xls should be opened as read-only unless you need to save changes to it. Open as read-only?" YES NO CANCEL We use this feature as only a few staff actually change the document and many use it for reference. When I save the Document as an xlsx document, I can't find how to apply this feature. Any Ideas? After you have clicked save as, click the button on the lower left that says tools, then select general options and select "read only recommended" -- Regards, P...

Reading XML Encoding errors
I am programming an XML reader in VB.NET 2005 and it works fairly well. Once in a while though I encounter an old XML file without the header <?xml version="1.0" encoding="UTF-8"?> It craps out on the Load with an error similar to "Invalid character in the given encoding. Line 3, position 5475070". After some research the character in question is the copyright character. My question is how can i force the reader to assume UTF-8? It seems like my other newer files do not have this problem, just my older files. I want to be able to catch this error and then...

filing comments
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Hi, <br> Is there a way to create a table that places the added comments in one column and the highlighted section of text in the other column. <br><br>Not sure if that's quite clear. <br><br>When I have edited a document, I have all these comments in balloons and each is linked to a section of highlighted text. I want to be able to create table with each row being a highlighted section of text in one column and the linked comment in the other column. Yes it could make for some...

Count specific word in a specific range
Hi Im having a few problems with a some excel formula's 1: I need a formula which will calculate a specific word in excel (specific word=Industrial) I have already created a formula =COUNTIF(H10:E12,"*industrial*") It works fine in one specific range (E.g H10:E12). I need to add another range in that formula. Everytime i try, i get an error message. E.G H10: E12 AND F14:G20 2: In the same spreadsheet i have filled in some cells with different colours, using the fill tool Red Blue Green I need a forumla which will calculate each Red cell in a given range? I need a forumla whic...