473,657 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading XML attributes with C#

Why do I always get '0' for attribute when i have tags like:
<GNRS someAttribute=" 12">Some Text</GNRS>

I read the attribute with:

aReader.GetAttr ibute("someAttr ibute");

where aReader is a XmlTextReader type
Nov 12 '05 #1
1 20336
Mystique wrote:
Why do I always get '0' for attribute when i have tags like:
<GNRS someAttribute=" 12">Some Text</GNRS>

I read the attribute with:

aReader.GetAttr ibute("someAttr ibute");

where aReader is a XmlTextReader type


Make sure the reader is positioned at GNRS element start tag when you
call aReader.GetAttr ibute("someAttr ibute").

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

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

Similar topics

3
9368
by: Carl Lindmark | last post by:
*Cross-posting from microsoft.public.dotnet.languages.csharp, since I believe the question is better suited in this XML group* Hello all, I'm having some problems understanding all the ins and outs with datasets and datatables (and navigating through the filled datatable)... Just when I thought I had gotten the hang of it, another problem arose: I can't seem to access the "xsi:type" attribute. That is, the XML file looks
6
10211
by: Hans Kamp | last post by:
My program fails reading XML attributes. A fragment of the code is: private void showXmlNodeAtTreeNode(XmlNodeList xnl, TreeNode tn) { int i; for (i = 0; i < xnl.Count; i++) { XmlNode xn = xnl; XmlNodeType nodeType = xn.NodeType;
9
1988
by: Xarky | last post by:
Hi, I am writing an XML file in the following way. Now I need to read again that file to retrieve data such as Name and Age. Can someone help me out. Thanks in Advance /*********************************/ static void writeXML() {
1
1294
by: Maziar Aflatoun | last post by:
Hi everyone, I like to use the dataset object for reading the following XML. <?xml version="1.0" encoding="utf-8"?> <ORDERS> <ORDER> <GENERALCONTACT> <FirstName>FirstName1</FirstName> <LastName>LastName1</LastName>
1
2083
by: SteveB | last post by:
I'm porting an application from Apache Xerces to .Net and am having a couple of small problems with deserialization. The XML that I'm reading comes from a variety of sources, and there are two inconsistencies that Xerces is able to handle that XmlSerializer seems not to be able to deal with. 1) Some of the boolean values that I'm dealing with are "True" and "False" rather than "true" and "false". I'm not quite sure whether "True" and...
4
1969
by: sherifffruitfly | last post by:
Hi, I have an xml file with structured like this: <?xml version="1.0" encoding="UTF-8"?> <Soldiers> <Soldier name="Billy Smith" rank="Private" serial="34" /> (a bunch more soldiers)
1
3672
by: tdpriya1984 | last post by:
Hi, Is it possible to fetch the Elements and Attributes in XML by reading the XSD?? I want to develop a application whose Elements and Attributes changes when i change my Schema. The Elements and Attributes will be displayed in the Form to fetch the user input and the new node will be appended to the existing XML. Any help regarding this would be of great help. Thanks in Advance.
1
2289
by: nitusa | last post by:
Hi All, First time poster, and newbie C# programmer so be patient with my ignorance. :) For my current project I need to store some information (install dir., file names, passwords, ect.) and then have my program access those values. I choose to store the information in an XML file based on a recommendation from a peer. I am also new to XML but my current file setup looks like this: <?xml version="1.0" encoding="utf-8" ?>...
3
1566
by: vb2008 | last post by:
So I am trying to figure out a new part now but I am getting stuck once again and yes I have been reading up on things and I think I know what my problem is I am just not sure how to fix it. Below is the XML I am trying to read. I need to be able to have the user type in a user they are looking for which is assigned to the Role_Search_Value_1.Text box. Then when it finds that user, I want to capture the permissions for that user. So far I have...
1
2752
by: Demon4231 | last post by:
I have a XML file that stores information about an application I am trying to read and it looks like this: <Data> <Login UserName="Username" Password="Password"/> <Application Name="AppName1" Key="Key1" Owner="Owner1"/> <Application Name="AppName2" Key="Key2" Owner="Owner2"/> <Application Name="AppName4" Key="Key3" Owner="Owner3"/> <Owner Name="Owner1"/> <Owner Name="Owner2"/> <Owner Name="Owner3"/>
0
8427
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.