Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 27th, 2007, 05:21 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default XPATH removing nodes from file??

Hello everyone,
    This seems to be a somewhat odd problem that I am having so I hope someone can shed some light on the subject. I have a specialized XML file that implements XFDL (it is a source document for IBM's Workplace Forms) and it is structured much like that of a plain run of the mill XML document albeit its DTD defines alot of custom tags.

Here is my situation: These files are to be uploaded through a Webform and stored in an image column inside of SQL Server. This protion of the application works wonderfully, however, before I get to this step I have to open the file and grab a piece of data from a particular node.

Since this file doesn't exist on the file system, I am opening the file from the input stream such as this:

Code:
XmlTextReader xtr = new XmlTextReader(userPostedFile.InputStream);
XPathDocument xDoc = new XPathDocument(xtr);
XPathNavigator xNav = xDoc.CreateNavigator();
XPathNodeIterator xIter = xNav.Select("//PAGE1");
This works fine and I am able to load the entire file into the XPathDocument and the node that I need is a child of <PAGE1></PAGE1>

So I wrote a loop:
Code:
while (xIter.MoveNext())
{
//loop till we get to the node <ClientNo></ClientNo>
}
However, I never reached the ClientNo node so I setup a hook right before the begining of this loop to see how many times it executed and, to my suprise, it didn't execute at all.

I then added this directly before the loop to see what data my Iterator was holding:
Code:
Response.Clear();
Response.ContentType = "text/xml";
Response.Write(xIter.Current.ToString());
Response.End();
This errored on me when it went to display as IE said it was not a valid XML document, however just doing

Code:
Response.Write(xIter.Current.ToString());
Writes out the entire file to the screen void of all Tags.

A sample of the file looks like this:
Code:
<PAGE1>
<navigation></navigation>
<FormProviderAgency>CSS</FormProviderAgency>
<ClientName readonly="true">Artifical Client</ClientName>
<ClientNo>2006821</ClientNo>
<DateOfAdmission>20060330</DateOfAdmission>
<PresentingProblem>Test symptoms</PresentingProblem>
...
</PAGE1>
But it literally gets wrote out as:CSSArtifical Client200682120060330Test symptoms

Does anyone have any idea as to why all of the tags would be seemingly stripped away? Does it have to do with the fact that I am working with it as a Stream as opposed to opening a source document on the filesystem? (Though I am not sure why that would make any difference.)

Any help would be greatly appreciated.


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #2 (permalink)  
Old February 27th, 2007, 05:37 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

>< Upon testing this a little farther, I created a text file and dumped all of the data into that text file and , upon opening the file, the data was persisted exactly as it appears in the source document?

I could turn around and use this file as the source document for my XPathDocument, however, I would like to handle everything in memory without writing a file down to the server.

Any thoughts?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing duplicate nodes post-process QuickSilver002 XSLT 3 April 4th, 2007 03:47 PM
How to use Xpath to extract child nodes smilysuresh XSLT 3 February 23rd, 2007 06:32 AM
Removing nodes with an XSLT Jza XSLT 2 April 19th, 2006 10:06 AM
XPath not finding nodes, need help Alderian72 XSLT 1 June 16th, 2005 10:49 AM
XPath - Selecting nodes based on attribute values billy_bob_the_3rd XML 4 December 1st, 2004 06:12 PM



All times are GMT -4. The time now is 03:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.