XmlTextReader Problem

Hi ,
	I am using XmlTextReader in C# code, I have one problem while reading
xml file with "XmlTextReader" class.
i.e I have traverse all attributs/child node of the xmlnode, After
that, I want to read outerXml of my current Xmlnode. but I am unable
to get outerXml node.
Here I am explaining my problem with sample snippet for simplifying
the understanding.

<CategoryList>

  <Category id = "0" language = "VC++">
    <Description>VC++ Articles</Description>
    <Active>Yes</Active>
  </Category>
	.............
  <Category></ Category >
	.......
</CategoryList>

In above code we have <category> nodes and it has some attributes and
child nodes. so I have traverse all the child nodes and attributes of
<Category> node.
	Now my problem is after traverse I want to read the Category node
outerXml(),

So any body can help me out how to do this.

Regards,
RS.

0
9/7/2007 1:56:27 PM
dotnet.xml 7266 articles. 0 followers. Follow

5 Replies
602 Views

Similar Articles

[PageSpeed] 12

Rasheed wrote:

> In above code we have <category> nodes and it has some attributes and
> child nodes. so I have traverse all the child nodes and attributes of
> <Category> node.
> 	Now my problem is after traverse I want to read the Category node
> outerXml(),

That is not possible, the reader works forwards only and once you have 
already traversed the children of an element node you can't move back to 
the element node to read its complete OuterXml, you would have to do 
that when the reader is positioned on the element node. So you can't 
have both with one reader, either you read the OuterXml of an element or 
you traverse its children, both move the reader forward and as you can't 
move backwards there is no way to do both steps with the same reader for 
the same node.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
9/7/2007 3:08:09 PM
Thanks Martin
So only way is to use XmlDocument obj and loding the xmlfile.
if any otherway around to do this. please suggest me the best if any
exist.

regards,
RS

0
9/7/2007 5:32:13 PM
Can i convert XmlTextReader to a Xmlnode.

regards
RS.

0
9/7/2007 5:46:30 PM
Rasheed wrote:

> So only way is to use XmlDocument obj and loding the xmlfile.
> if any otherway around to do this. please suggest me the best if any
> exist.

XPathDocument/XPathNavigator in .NET 2.0 and later should suffice as 
long as you only want to read out data, it has a property OuterXml:
<http://msdn2.microsoft.com/en-us/library/System.Xml.XPath.XPathNavigator.OuterXml.aspx>

You only need XmlDocument if you want to remove/change/insert nodes.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
9/8/2007 12:29:51 PM
Rasheed wrote:
> Can i convert XmlTextReader to a Xmlnode.

XmlDocument has a method ReadNode that takes an XmlReader and returns an 
XmlNode:
<http://msdn2.microsoft.com/en-us/library/System.Xml.XmlDocument.ReadNode.aspx>

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
9/8/2007 12:31:25 PM
Reply:

Similar Artilces:

Problem sending email from Outlook
Hello, Wierd problem here. WE run Office/Outlook 2000 SR-1 (9.0.0.3821) on Windows 2000. There is an Exchange server on our network. Our domain however is not registered. We have an ISP that provided a domain name for us for email purposes. Problem: We have 1 user who has an Internet mail account. This account is configured correctly in Outlook. However, Outlook will not send an email to certain accounts. I have email with a local ISP, also with Hotmail and Yahoo. This user can successfully send email to Yahoo and Hotmail but not others. AOL accounts also appear unreachable. We'...

XmlTextReader Help!!!
Hi, Ok, so here's my problem. I'm trying to read an xml file using an XmlTextReader. The file itself is simple. What I'd like to do is compare each node's value attribute to another string. If they are the same, I'll retrieve the text of the node and do some mumbo-jumbo with it. Here's what my xml file looks like (note that it contains lots more nodes): <Fruits> <fruit value="007">Mango</fruit> <fruit value="010">Pineapple</fruit> <fruit value="489">Tangerine</fruit> <fruit value...

DVD problem
WIN XP SP3 plus all updates. Back in Dec 2009 I purchased a new LiteOn IHAP322-22x DVD. I have recently been using it to boot my computer as I have been getting intermittent BSODs so I have been using an iso boot disc when needed. Having been able today to start the computer, without needing the boot disc, I took the opportunity to do a backup. After doing this I checked to see that all was safely on the disc only to find it was blank - nothing showing. I put the disc into a laptop and all the backup folders were there. I have since put in other different types of discs, DV...

richedit2 mfc problem? #3
Good morning, I try using richedit2 under Visual Studio 2003 but i have problem run it. I only add this control from toolbar menu to my dialog box ,but when i give compile it aplication out...not show compiled dialog box and one error...The program '[3076] sk4.exe: Native' has exited with code 0 (0x0). all another control object works fine...only richedit2 made problem.... in old version visual studio 6 and net works too richedit without problem Is there something what i must add? Thanks Zidek ...

problems with imported dates
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Power PC I am importing data with dates that range from 1887 to 1950s. Excel keeps the 1880s dates, but either subtracts or adds 4 years and one day to all of the 1900s dates. I have tried reformatting the dates in the source information, reformatting in excel and copying to another spreadsheet, using different date formats to move the data, etc. nothing seems to work. <br><br>If there is anything this program should do, its process dates correctly. This is a major issue when accuracy is involved and is wor...

GPO problem
Hi Suddenly in our Windows 2003 R2 member server in event log the following error appeared Windows cannot obtain the domain controller name for your computer network. (An unexpected network error occurred. ). Group Policy processing aborted. It repeats every one hour. We haven't changed anything on server or on a domain environment. Have checked DNS and network settings and all look right. Any ideas what to do to solve this? Regards, Miha Hello Miha, Please post an unedited ipconfig /all from the server and your DC/DNS server also. Additional post ...

SUMPRODUCT Problem #3
I would appreciate any thought on this curiosity. In A1 I have a number - 25,000 In B1 I have another number 0.95. I also have a cell with the formula =SUMPRODUCT(A1:B1)/SUM(A1) Usually I have a number of rows with similar numbers in the respective columns and the formual expands to accomodate these rows. For some reason the formula gives me the result 1.00 when it should clearly be 0.95. The problem does not seem to arise when there is more than one row. Any thoughts? try =SUMPRODUCT(A1,B1)/SUM(A1) -- Regards, Peo Sjoblom (No private emails please, for everyone's benefit k...

problem with pasting & #value
Hi, I hope some one can help. I have created a spreadsheet to extract data and sort it int individual worksheets for the work, units and time individuals hav done daily. This data is then copied to the bosses non modifiabl spreadsheet. My problem is: I am trying to copy& paste data from my SS with formulas to to th other. The cells pasted into only have formatting of numbers and time The pasted blank cells with "" criteria return a #value in th calculations column of the bosses. Can anyone help with a means o removing what I assume are non priting characters being pasted from...

If..Then Statement Problem
I have figured out the first part of this problem, but can't seem to ge any farther. Here's what I need Basic synopsis: each client has a different percentage to which thei invoices are multiplied, i.e., Column A is the client name, Column B i the total invoice amount, Column C is the percentage of the invoice. If Column A = "AAA" then the percentage is 50%, so whatever Column is, Column C will calculate at 50%. If Column A = "BBB" then th percentage is 75%, and whatever is inColumn B will calculate int Column C at 75% I have gotten as far as if Column A = &q...

problem with saving
When I tried to save a changed file, I got error: "could not save because of sharing violation." Never saw this before. So I had to save to a new file name. On Dec 18, 7:33=A0pm, "amc" <fort...@yahoo.com> wrote: > When I tried to save a changed file, I got error: "could not save because= of > sharing violation." > =A0 =A0Never saw this before. So I had to save to a new file name. Are you working on a Network pc? If yes, then, it may be something else has opened that file. ...

Sorting problem #8
Hi, I am running WinXP and Office 2003 with all updates installed. I have my firewall email me the log each day which I then paste into Excel. The data is in the format Col. A Col. B Col. C Col. D Date & time Action taken Source IP address, port Destination IP address, port 2005/01/14 21:24:53.480 - UDP packet dropped - Source:w.x.y.z, port, WAN - Destination:w.x.y.z, port, WAN - wh...

Access-Excel querry problem
Hi I created two days ago access data base then today I wanted to link one querry to excel by Data/Import external data/import data And I can only see the original querries I created 2 days ago, I don't see the one I created today What should I do? -- Greatly appreciated Eva ...

Problem with XMLDataDocument...
I'm relatively new to this sort of thing, so forgive me if this is completely off base, but I'm having a problem getting the XMLDataDocument to do what I need it to. I have a small test application that has a DataSet with two data tables, Person and Home. I've setup Home as a child of Person. What I want to do is to load data into these two tables, and then have the data document create the xml with the child nodes (home) nested under the parent node (person). Is this possible??? The code snippet I have to load and output the xml is as follows: DsTester ds = new DsTester(); D...

Problem with Hook
You can view my source at the following: http://www.qtextender.com/code/DllMain.cpp http://www.qtextender.com/code/DllMain.h I call the InstallShellHook() function within my DLL and it seems that the only shell hook notifications I receive are for the actual application that I am debugging. I start Notepad, or any other application and I don't receive a HSHELL_WINDOWCREATED, HSHELL_WINDOWACTIVATED, or any other message for that matter. Any ideas as to why the hook callback would only be triggered for the application that installed the hook? TIA. [CppNewB] > the only shell...

pop-up form/message box problem
I have a main form where records are entered; in one field users select from a list of citations, if they type something that's not on the list, a message box pops up asking if they'd like to add the new citation, when they click "yes" the pop-up form where they enter the citation information opens, no problem. HOWEVER, if they close the pop-up form without entering any data the default Access message " The text you entered isn't an item in the list." appears. How do I prevent that from happening? -- Message posted via AccessMonster.com http://www.accessmon...

Problem sending large attachment
Want to send a 27mb file by email, but cannot... Outlook sent it yesterday, but then would not do it again. Very irritating. I cannot see what to do to change this....any ideas please? I use Windows XP, Outlook 2003 and BT internet. Thanks "Julie" <poohsnews@btopenworld.com> wrote in message news:5tSdnff3fP4BL7zUnZ2dnUVZ8sXinZ2d@bt.com... > Want to send a 27mb file by email, but cannot... Outlook sent it > yesterday, but then would not do it again. Very irritating. > I cannot see what to do to change this....any ideas please? > I use Windows XP, Outlook 2003 ...

XmlTextReader Question
I have the following XML i do the following to extract the name information XmlTextReader Reader = new XmlTextReader("C:\\names.xml"); while(tempReader.Read() ) { if(tempReader.Name.ToLower() == "name ") { //My problem here how to get firstname and last for the current name node by other words get the childs information from parent node } } <family> <name gender="Male"> <firstname>Tom</firstname> <lastname>Smith</lastname> </name> <name gender="Female"&g...

index_files : Directory Publishing Problem
Each time I publish my site to the web using Publisher I have to go into the index.htm file and remove index_files from the paths (currently about 300 times) This is getting annoying. How do I make publisher do it right? The other things is it puts all my files in www.a45.i8.com/index_files instead of using the root path of www.a45.i8.com. Please help this is getting bad! Adam6979 wrote: > Each time I publish my site to the web using Publisher I have to go into the > index.htm file and remove index_files from the paths (currently about 300 > times) This is getting annoying. Ho...

OWA problem #2
Can somebody help with this problem. When using OWA, it does not allow me to reply to emails that I read. When I click reply, it closes out. To reply to emails, I have to copy and paste the address into a new message. How can I fix this problem. Thanks. "Someone" <anonymous@discussions.microsoft.com> wrote in news:038c01c3d957 $6f61ac00$a401280a@phx.gbl: > Can somebody help with this problem. When using OWA, it > does not allow me to reply to emails that I read. When I > click reply, it closes out. To reply to emails, I have to > copy and paste the addres...

Problems using Word as Editor
Am using Office/Outlook 2000. My OS is Windows XPMCE. This just started where I get this error statement: Can't open this item. Microsoft WordMail could not be started. Try one of the following: Close any open dialog boxes in Word. Make susre Word is installed correctly. Close other programs and try again. If I quit Word from the task box or restart my computer, I can open an email and read it in Word because the computer reloads it. If I try to open another or try to write an email I get the message. I've tried reinstalling Office but the problem still persists. I've never had th...

AppleSyncNotifier problem
when i log on to windows vista i recieve an error message "AppleSyncNotifier has stopped working" Windows will automaticaly search for the fix and then it will just ask me to close the program as it does not have a fix. I do not have this program in the programs list. Does anyone know how to resolve this issue?-Thanks in advance-John iTunes? Mobile Me? some program from Apple installed this.. disable it either in the Startup group or by running msconfig. On Wed, 2 Jun 2010 10:55:02 -0500, "John Webb/April Diamonds" <john@aprildiamonds.net> wrote: ...

Problem with LoadCursor
Hi all... In the Create method of a CWnd derived class I have this call: if (m_hSplitter == NULL) { m_hSplitter = ::LoadCursor(GetModuleInstance(), MAKEINTRESOURCE(IDC_SPLITTER)); TRACE("%ld", GetLastError()); } This control belongs to an extension DLL. GetModuleInstance correctly gets the instance of it, and IDC_SPLITTER is a cursor resource contained in the corresponding RC file. After the LoadCursor call, m_hSplitter has a NULL value, and GetLastError reports: 1813 The specified resource type cannot be found in the image file. ERROR_RESOURCE_TYPE_NOT_FOUND I tri...

Wordwrap problem
I'm using Publisher 2002 SP3, as well as Publisher 2007. No matter what I do, I can't get text to wrap around a picture placed inside a text box. The text simply flows through the picture. I have tried to use the inclluded help files, but to no avail. Anyone have some suggestions? Jeff I'm a 2000 user which the fix is, Click on the word text box, Format Text frame properties Options Wrap text around objects. -- Don Vancouver, USA "Jeff Stanton" <jstanton@hughes.net> wrote in message news:CryHj.1014$3N1.932@newsfe17.lga... > I'm using Publish...

Partition Problem
Got a wierd one for ya. Everything was going along as normal and then all of a sudden, while out at lunch, our exchange server stopped working. 12 hours later I got it running after several chkdsk, defrag, repeats based on the error messages. The information store is safe and sound and so is the log store. But the drive with the OS on is freaking me out. Under disk management, the graphic display shows 21.77GB of HD space in the C: drive partition. Up top in the list view it shows 12.00GB. dbl-click my computer and C: drive is 12.00GB. What has happened to my partition? ...

Input position of current Node in XmlTextReader
Hello, Perhaps it's obvious, but I don't find any property in XmlTextReader to obtain the position of the current node. I know that I can obtain the position of the node in the current line (LinePosition) and the line number, but I need to know the position relative to the whole document. Thanks :-) alessnet@gmail.com wrote: > Perhaps it's obvious, but I don't find any property in XmlTextReader > to obtain the position of the current node. > I know that I can obtain the position of the node in the current line > (LinePosition) and the line number, but I need to ...