Solved

Best way to phrase XML file

Posted on 2006-06-20
5
297 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Achieve json result 2 64
Adjust the position 3 45
Two different visual studio versions 3 21
Entity Framework 7 27
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now