Get Element Value

J

Jay

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.
 
J

Jay

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.
 
J

Jay

Thank you for the reply. Not quite sure what you mean.

I need both the entire outerxml as well as a few individual element values.
Would I use a loop inside the loop?
 
G

Guest

The XML I'm using comes from SQL Server 2005 and isn't very large at all. I
am having a difficult time with the loop used to capture the individual
element values as well as the outerxml. Would you happen to know of an
example illustrating this or tutorials on accomplishing this? Thank you
very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top