473,396 Members | 2,013 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.

XMLReader or XMLDocument ?

How do I read the attributes of this XML? I have a page with text boxes that
i want to read
these values in. notice there are 2 Parameter tags with the same attributes.
Code would help
<TranslationRecords>

<TranslationRecord TrxID="1">

<ParameterCollection>

<Parameter KeyName="FielDelimiterChar" KeyValue="29" />

<Parameter KeyName="SegmentDelimiterChar" KeyValue="30" />

</ParameterCollection>

</TranslationRecord>

</TranslationRecords>

Thanks

Nov 18 '05 #1
1 1328
Hi there,

For small documents, it's the easiest to use XMLDocument.
Then, you can either read elements from it, or use XPath.

In your case, something like the following should work:

XmlDocument doc = new XmlDocument();
doc.Load(...);
XmlElement root = doc.DocumentElement; // TranslationRecords
XmlNode id = root.SelectSingleNode("TranslationRecord/@TrxID");
if (id != null)
return id.Value;

In case of multiple nodes, you can use SelectNodes and iterate the result.

Hope this helps,
Michel

<jo*****@hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP12.phx.gbl...
How do I read the attributes of this XML? I have a page with text boxes that i want to read
these values in. notice there are 2 Parameter tags with the same attributes. Code would help
<TranslationRecords>

<TranslationRecord TrxID="1">

<ParameterCollection>

<Parameter KeyName="FielDelimiterChar" KeyValue="29" />

<Parameter KeyName="SegmentDelimiterChar" KeyValue="30" />

</ParameterCollection>

</TranslationRecord>

</TranslationRecords>

Thanks

Nov 18 '05 #2

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

Similar topics

2
by: xmlguy | last post by:
This is part of the application that reads XML from file (that has UTF-8) into an XmlTextReader XmlTextReader myXmlReader = new XmlTextReader(args); It then instantiates an object/class...
1
by: Logician | last post by:
Task: To Read an XML document and handle data contents in .NET for new processing Request: Any details on how to read an XML document processing all nodes and content in .NET Problems:...
8
by: Charles.Deisler | last post by:
Im currently using the following code.. XmlDocument xmlData = new XmlDocument(); XmlTextWriter xmlwriter = new XmlTextWriter(Response.OutputStream,System.Text.Encoding.UTF8); XmlReader...
2
by: muesliflakes | last post by:
I wish to receive some data from SqlServer as XML and write out result to as a string. Eg: cmd = new SqlCommand( "select * from blah for xml auto", con ); XmlReader result =...
8
by: terrorix | last post by:
I also posted this article at: microsoft.public.dotnet.framework.aspnet -------- Hi, I Have this sql select(MS SQL): select a.ID, b.ID from Table as a
0
by: Jeff | last post by:
Hi, I am trying to use the XML Web Control and the XmlReader but when I try and load the xmlReader into the XmlDocument is gives me this error Error: This document already has a...
10
by: Thirsty Traveler | last post by:
All of the XmlReader examples assume that the XmlDocument is being read from a file. However, I would like to use it with an XmlDocument passed as a method parameter, but am not sure how. Any...
2
by: raj | last post by:
i have this code which is upgraded to work with 2.0 and works great with framework 1.0 and 1.1 without the upgraded code. //2.0 code// public static XmlReader RtfToXml( string Rtf ) { if (...
1
by: engwar | last post by:
The title says it all. How do I use XMLDocument.Validate() against a DTD. In all my Googling about this I only find examples of how to validate an XMLReader or XmlValidatingReader against a DTD....
2
by: SammyBar | last post by:
Hi all, I'm trying to convert the xml obtained from a XmlReader object into a UTF-8 array. My general idea is to read the XmlReader and write into a MemoryStream. Then convert the MemoryStream...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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...

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.