Thanks for the reply.
This seems to work well, however, I am faced with a problem...
I need to get the etire ReadOuterXML for each of the individual records as
well as a few of the element values within that record.
So with XML like so:
<Customer>
<custno>2</custno>
<lname>Doe</lname>
<fname>John</fname>
<address>123 4th st.</address>
</customer>
<Customer>
<custno>3</custno>
<lname>Smith</lname>
<fname>Terry</fname>
<address>456 7th St.</address>
</customer>
I need to return (in a loop) something like this:
varOuterXML =
"<Customer><custno>2</custno><lname>Doe</lname><fname>John</fname><address>123
4th st.</address></customer>"
varLName="Doe"
varFName="John"
varOuterXML =
"<Customer><custno>3</custno><lname>Smith</lname><fname>Terry</fname><address>456
7th St.</address></customer>"
varLName="Smith"
varFName="Terry"
I am using while xmlreader.readstate <> xml.readstate.endoffile but cannot
seem to get this to work together.
Any suggestions would be greatly appreciated.
Thanks a lot.
"Gaurav Vaish (EduJini.IN)" <ga*****************@nospam.gmail.com> wrote in
message news:uw*************@TK2MSFTNGP04.phx.gbl...
while(reader.Read())
{
if(reader.NodeType == XmlNodeType.Element)
{
_name = reader.Name;
if(reader.read())
{
if(reader.NodeType == XmlNodeType.Text)
{
_value = reader.Value;
}
}
}
}
or
string _name;
string _value;
while(r.Read())
{
switch(reader.NodeType)
{
XmlNodeType.Element: _name = reader.Name;
break;
XmlNodeType.Text: if(_name != null)
{
_value = reader.Value;
_name = null;
} // Reset the _name after the value
has been found
}
}
HTH
--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://www.edujini.in
-------------------
"Jay" <msnews.microsoft.com> wrote in message
news:eK**************@TK2MSFTNGP04.phx.gbl... In a loop like so:
...
xmlr=cmd.executexmlreader()
xmlr.read()
do while xmlr.readstate <> xml.readstate.endoffile
loop
How do I return each individual element name and value from a document
like so:
<Customer>
<custno>2</custno>
<lname>Doe</lname>
<fname>John</fname>
<address>123 4th st.</address>
</customer>
So the result I need in the loop is (output to textbox):
custno: 2
lname: Doe
...
Thanks a lot.