473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Read XML file

Hi

Here's my problem. Actually I have an XML file like this :

<?xml version="1.0" encoding="utf-8"?>
<ApplicationSettings>
<Section Name="Transfert">
<Key Name="m_blnTransfRoleBD" Value="True" Comment=""/>
<Key Name="m_blnTransfRoleHyper" Value="False" Comment=""/>
<Key Name="m_blnTransfCRBD" Value="False" Comment=""/>
<Key Name="m_blnTransfCRHyper" Value="False" Comment=""/>
<Key Name="m_lngDelai" Value="30" Comment=""/>
</Section>
</ApplicationSettings>

I'm able to read value of my key but I want to read comment also. How
I can make to read comment using Section Name and Key Name ?

Thanks
Nov 11 '05 #1
3 2729
Eric Caron wrote:
Here's my problem. Actually I have an XML file like this :

<?xml version="1.0" encoding="utf-8"?>
<ApplicationSettings>
<Section Name="Transfert">
<Key Name="m_blnTransfRoleBD" Value="True" Comment=""/>
<Key Name="m_blnTransfRoleHyper" Value="False" Comment=""/>
<Key Name="m_blnTransfCRBD" Value="False" Comment=""/>
<Key Name="m_blnTransfCRHyper" Value="False" Comment=""/>
<Key Name="m_lngDelai" Value="30" Comment=""/>
</Section>
</ApplicationSettings>

I'm able to read value of my key but I want to read comment also. How
I can make to read comment using Section Name and Key Name ?


Which API are you talking about - XmlReader, XPathNavigator, XSLT,
XmlDocument?? All of them allow you to read XML and all use different
approaches.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
Hi

I use XMLDocument

On Fri, 19 Sep 2003 19:36:34 +0300, Oleg Tkachenko
<oleg@NO_SPAM_PLEASEtkachenko.com> wrote:
Eric Caron wrote:
Here's my problem. Actually I have an XML file like this :

<?xml version="1.0" encoding="utf-8"?>
<ApplicationSettings>
<Section Name="Transfert">
<Key Name="m_blnTransfRoleBD" Value="True" Comment=""/>
<Key Name="m_blnTransfRoleHyper" Value="False" Comment=""/>
<Key Name="m_blnTransfCRBD" Value="False" Comment=""/>
<Key Name="m_blnTransfCRHyper" Value="False" Comment=""/>
<Key Name="m_lngDelai" Value="30" Comment=""/>
</Section>
</ApplicationSettings>

I'm able to read value of my key but I want to read comment also. How
I can make to read comment using Section Name and Key Name ?


Which API are you talking about - XmlReader, XPathNavigator, XSLT,
XmlDocument?? All of them allow you to read XML and all use different
approaches.


Nov 11 '05 #3
Eric Caron wrote:
I use XMLDocument


So you have two options to consider - either iterate to the Key element
you need and then get Comment attribute value using GetAttribute method
or select appropriate value directly using XPath - say to select Comment
attribute of Key element, whose Name attribute is m_blnTransfCRBD, you
can use something like

XmlNode commentAttr =
doc.SelectSingleNode("/ApplicationSettings/Section/Key[@Name='m_blnTransfCRBD']/@Comment");

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Yang Li Ke | last post by:
Hi guys! I have some datas that I must check everytime a visitor comes to my site What is better to do: 1- Read data from a file or 2- Read data from a mysql db Thank you
10
by: ZafT | last post by:
Thanks in advance for any tips that might get me going in the right direction. I am working on a simple exercise for school that is supposed to use read to read a file (about 10 MB). I am...
1
by: cnu | last post by:
My program generates a log file for every event that happens in the program. So, I open the file and keep it open till the end. This is how I open the file for writing: <CODE> public...
4
by: ESPN Lover | last post by:
Below is two snippets of code from MSDN showing how to read a file. Is one way preferred over the other and why? Thanks. using System; using System.IO; class Test { public static void...
8
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
5
by: lovecreatesbea... | last post by:
The condition at line 31 is added to check if the program finished to read the whole file. Is it needed and correct? Thank you. #include <fstream> #include <iostream> #include <string> using...
0
by: lovecarole | last post by:
hi, i am the student who should write a program about reading wav file and do the DFT. actually i don't know how to read data of the wav song and save it into the array... if i want to read...
6
by: Thomas Kowalski | last post by:
Hi, currently I am reading a huge (about 10-100 MB) text-file line by line using fstreams and getline. I wonder whether there is a faster way to read a file line by line (with std::string line)....
9
by: flebber | last post by:
I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b") and write it out . the compressed "*.k3b" file has two file and the one I was trying...
2
by: Kevin Ar18 | last post by:
I posted this on the forum, but nobody seems to know the solution: http://python-forum.org/py/viewtopic.php?t=5230 I have a zip file that is several GB in size, and one of the files inside of it...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.