Solved

Best way to phrase XML file

Posted on 2006-06-20
5
299 Views
Last Modified: 2011-10-03
I have a XML file with the following structure:

<?xml version="1.0" encoding="utf-8" ?>
<root>
      <content>
            <item id="1"><![CDATA[ The value 1 goes here ]]></item>
            <item id="2"><![CDATA[ The value 2 goes here ]]></item>
            <item id="3"><![CDATA[ The value 3 goes here ]]></item>
            <item id="4"><![CDATA[ The value 4 goes here ]]></item>
      </content>      
</root>


What's the best way to phrase the file in order to get the value
for item id say 3 ?

I'll be making a lot of hits for the file, so ideally the read
would be from cache. Any example you can provide would be greatly
appreciated. Thanks.


I work with VB.NET on .NET 2.0.

0
Comment
Question by:vpekulas
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
rodmjay earned 500 total points
ID: 16946963
Probably the xmlDocument.GetElementbyID method would work the best

Here is code that does what you want

dim xmldoc as new xmldocument

dim value as string = xmldoc.getelementbyid("3")

http://msdn2.microsoft.com/en-us/library/system.xml.xmldocument.getelementbyid.aspx
0
 
LVL 8

Expert Comment

by:rodmjay
ID: 16946975
excuse me that would be dim value as string =  xmldoc.getelementbyid("3").innertext
0
 

Author Comment

by:vpekulas
ID: 16947389
OK, that looks promising, now how do I cache the read (not look-up) so I don't have
to open the xml file each and every time ?
0
 

Author Comment

by:vpekulas
ID: 16947390
Nevermind, I got it :)
0
 

Author Comment

by:vpekulas
ID: 16948231
I take it back, this doesn't work without having to declare the XML structure.
I only have the XML as noted back.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question