Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 19th, 2005, 04:59 PM
Authorized User
 
Join Date: Jun 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default XmlTextReader (.NET) - outputting the xml

Hi all,

I simply want to read from an xml document and output a subset of it to a string. That is, consider the following xml:
Code:
<animals>
    <fish type='water'>SwordFish</fish>
    <monkey type='land'>Ape</monkey>
</animals>
I use an XmlTextReader to read through this xml. When I read the <monkey> element I want to output the xml to a string so that my string will look like:
Code:
string = "<monkey type='land'>Ape</monkey>
When I use the ToString() method my string contains just the text value of the element (string = "Ape").

How can I get the actual xml?

Thanks!

 
Old January 20th, 2005, 11:46 AM
Authorized User
 
Join Date: Jun 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually, XmlTextReader has a method called ReadOuterXml() that does exactly this. What I meant to say was XPathDocument instead of XmlTextReader.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Not outputting a specific node zach_1988 XSLT 3 December 2nd, 2008 10:49 AM
Outputting Array manih C++ Programming 2 June 14th, 2006 08:24 PM
Cloning a XmlTextReader billy_bob_the_3rd XML 0 March 28th, 2006 06:42 PM
page numbering while outputting agbeltekin Javascript 5 November 13th, 2003 12:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.