CFanatic

Go Back   CFanatic > Programming > C# Programming

Join CFanatic Forum Now

C# and XML simple problem topic posted under C# Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2008, 02:19 PM
Junior Member
 
Join Date: Apr 2008
Location: Louisville,KY
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
lkytmr is on a distinguished road
| More
C# and XML simple problem

I have programmed in VB6 and VC but I am new to C# and XML and I can't seem to muddle my way through the simplest of problems.

Given an XML file below, I just want to know what the value of PI is. Why doesn't this work?

N = root.SelectSingleNode("descendant::variable[name='PI']");
Debug.Print(N.InnerText);

Thanks for listening.

Tom

XML File:
<?xml version="1.0"?>
<!-- Simple test XML file -->
<bookstore xmlns:bk="urn:samples">
<Variables>
<Variable name="PI"> 3.1415926535 </Variable>
<Variable name="Four"> 4 </Variable>
</Variables>
</bookstore>
Reply With Quote
  #2  
Old 04-14-2008, 02:19 PM
Junior Member
 
Join Date: Apr 2008
Location: Louisville,KY
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
lkytmr is on a distinguished road
| More
Re: C# and XML simple problem

Eventually found the answer. For anyone else stuck on this:

XmlNode N; string sVariable;

N = root.SelectSingleNode("//descendant::variable[name='pi']/value");
if (N != null)
{
sVariable = N.InnerText;
Debug.Print(sVariable);
}
Tom
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple class not working psppb C++ Programming 3 01-08-2008 10:24 PM
Simple encryption program Trebbert Win32 Programming 0 09-23-2007 04:09 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:35 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board