473,387 Members | 1,619 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,387 software developers and data experts.

Reding XML

(thanks to an earlier post) I've written some XML to a string using
XmlTextWriter and StringWriter. Which all works and creates XML like

<title000>abc</title000>
<url000>efg</url000>
<title001>abc</title001>
<url001>efg</url001>

Can someone please show me how I read this back using XmlTextReader -
specifically I want to be able to say "get me the contents of tag <title001>
and also tell me if this tag does not exist.

I just can't get any code to work
TIA

Nov 16 '05 #1
3 1163
hi
are you strict you want to use XmlText reader,i would prefer you go for a
dom parser

please check a similar posting to read from an xml document

regards
Ansil

http://www.msdn.microsoft.com/newsgr...7b3&sloc=en-us

"Tony" wrote:
(thanks to an earlier post) I've written some XML to a string using
XmlTextWriter and StringWriter. Which all works and creates XML like

<title000>abc</title000>
<url000>efg</url000>
<title001>abc</title001>
<url001>efg</url001>

Can someone please show me how I read this back using XmlTextReader -
specifically I want to be able to say "get me the contents of tag <title001>
and also tell me if this tag does not exist.

I just can't get any code to work
TIA

Nov 16 '05 #2
Yes - The following is what I want - but how do I pass a string containing
XML rather than point at an xml file?

here is the code
use Dom Parsing

XmlDocument objDoc=new XmlDocument();
objDoc.Load("a.Xml");
XmlNode objNode;
objNode= objDoc.SelectSingleNode("//QueryResult/HERE");
MessageBox .Show(objNode.InnerXml );

XmlNode objSecNode;
objSecNode= objNode.SelectSingleNode("ExternalIntegrator/Entities");
MessageBox .Show(objSecNode.InnerXml );

MessageBox.Show(objSecNode.ChildNodes[0].InnerText);
MessageBox.Show(objSecNode.ChildNodes[1].InnerText);
MessageBox.Show(objSecNode.ChildNodes[2].InnerText);

objDoc=null;

"Ansil MCAD" wrote:
hi
are you strict you want to use XmlText reader,i would prefer you go for a
dom parser

please check a similar posting to read from an xml document

regards
Ansil

http://www.msdn.microsoft.com/newsgr...7b3&sloc=en-us

"Tony" wrote:
(thanks to an earlier post) I've written some XML to a string using
XmlTextWriter and StringWriter. Which all works and creates XML like

<title000>abc</title000>
<url000>efg</url000>
<title001>abc</title001>
<url001>efg</url001>

Can someone please show me how I read this back using XmlTextReader -
specifically I want to be able to say "get me the contents of tag <title001>
and also tell me if this tag does not exist.

I just can't get any code to work
TIA

Nov 16 '05 #3
hi

replace the second line of code by the following

objDoc.LoadXml( myXmlString);

regards
Ansil

"Tony" wrote:
Yes - The following is what I want - but how do I pass a string containing
XML rather than point at an xml file?

here is the code
use Dom Parsing

XmlDocument objDoc=new XmlDocument();
objDoc.Load("a.Xml");
XmlNode objNode;
objNode= objDoc.SelectSingleNode("//QueryResult/HERE");
MessageBox .Show(objNode.InnerXml );

XmlNode objSecNode;
objSecNode= objNode.SelectSingleNode("ExternalIntegrator/Entities");
MessageBox .Show(objSecNode.InnerXml );

MessageBox.Show(objSecNode.ChildNodes[0].InnerText);
MessageBox.Show(objSecNode.ChildNodes[1].InnerText);
MessageBox.Show(objSecNode.ChildNodes[2].InnerText);

objDoc=null;

"Ansil MCAD" wrote:
hi
are you strict you want to use XmlText reader,i would prefer you go for a
dom parser

please check a similar posting to read from an xml document

regards
Ansil

http://www.msdn.microsoft.com/newsgr...7b3&sloc=en-us

"Tony" wrote:
(thanks to an earlier post) I've written some XML to a string using
XmlTextWriter and StringWriter. Which all works and creates XML like

<title000>abc</title000>
<url000>efg</url000>
<title001>abc</title001>
<url001>efg</url001>

Can someone please show me how I read this back using XmlTextReader -
specifically I want to be able to say "get me the contents of tag <title001>
and also tell me if this tag does not exist.

I just can't get any code to work
TIA

Nov 16 '05 #4

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

Similar topics

13
by: Gary | last post by:
Hi all, I have a situation where I need to generate a new binary file which just changes a couple of bytes in a couple of places in a pre-existing master template file. I can open and read...
2
by: Tony Johansson | last post by:
Hello! I know this is wrong NG but somebody might know this question. We are now talking about Component Object Model(COM). If you don't know COM stop reding here. Is COM class the class...
17
by: theDever | last post by:
hi .. I was used VB, Java, PHP and C# to developed my own software , but now I have a project in C++ , and I'm a bit confused ... In PHP,C# and Java , there are a framework that provide a wide...
4
by: laurenq uantrell | last post by:
Just trying out xp_smtp_sendmail for the first time. I get the error: Error: connecting to server smarthost OK, so I don't have the server parameter for SMTP server set up correctly. I don't...
0
by: TJS | last post by:
attempting to read a delimited text file into a dataset using oledb text file connection getting this error message when trying to open connection...
8
by: Al Kaufman | last post by:
I have a simple console app that uses: regSubKey = <some registry key> Dim reg As RegistryKey = Registry.ClassesRoot.OpenSubKey(regSubKey) Dim path As String path = CStr(reg.GetValue(""))
1
by: predoni | last post by:
Hello, I developed a program that monitor the registry. This program notify if one of the key is changed. The next step is to create the posibility to tell what process have modified the...
3
by: lakepeir | last post by:
Can anyone suggest some good online tutorials on creating a message board with ASP .NET? Thanks.
3
by: Harry | last post by:
#include<stdio.h> #include<stdlib.h> #include<malloc.h> void scramble(void); struct bmp_header { short int sig; int size_bmp;
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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...

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.