XmlTextReader URL Limitation???

I am feeding XmlTextReader a URL that returns the XML that then gets parsed.
The URL forms a query that affects how much data is returned in XML but not
the format of the data.

The problem is that when the URL string exceeds about 163 characters
(strange number) XmlTextReader seems to choke on it and it doesn't seem like
any XML is actually being returned and the code throws an exception on
reading the first element.  Shorter URL strings seem to work fine.  Strings
longer than ~163 chars work fine when pasted into a browser, so the server
is returning good XML.

Sorry for the long post.....
Code, XML, error msg follow:

Imports System
Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl
Imports System.Xml.Schema
Imports System.Collections

Module Module1
    Sub FPO_XmlQuery()
        Dim urlA As String
        Dim urlB As String
        Dim strMatches As String
        Dim intMatchCount As Integer
        Dim i As Integer

        ' this url will work.
        urla =
"http://www.freepatentsonline.com/xml-search.pl?type=uspatent&query=ttl/cryo
genic&sort=chron&date_range=all&start=51&session_id=ABCD123EFGHIJKLMNOPQRSTU
V"
        ' this url will fail.
        urlb =
"http://www.freepatentsonline.com/xml-search.pl?type=uspatent&query=ttl/cryo
genic&stemming=yes&sort=chron&date_range=all&start=51&session_id=ABCD123EFGH
IJKLMNOPQRSTUV"
        ' both urls return the exact same xml and both work fine if you
paste them into a browser and get the xml back.
        ' it appears that the length of the url string is an issue for
XmlTextReader.

        Dim r As XmlTextReader
        r = New XmlTextReader(urlA)   ' sub in urlA or urlB here or
"xm1.txt" to read the xml from a local file.
        r.ReadStartElement("results")      ' this is where the exception
error occurs with the "long" url
        strMatches = r.ReadElementString("matches")
        Console.WriteLine("matches: {0}", strMatches)
        Console.WriteLine("query: {0}", r.ReadElementString("query"))

        intMatchCount = 50     ' CInt(strMatches)

        For i = 1 To intMatchCount
            r.ReadStartElement("uspatent")
            Console.WriteLine("match: {0}", r.ReadElementString("match"))
            Console.WriteLine("document: {0}",
r.ReadElementString("document"))
            Console.WriteLine("title: {0}", r.ReadElementString("title"))
            Console.WriteLine("link: {0}", r.ReadElementString("link"))
            r.ReadEndElement() ' </uspatent>
        Next

        r.ReadEndElement() ' </results>

    End Sub



    Sub Main()
        Console.WriteLine("XML tests...")

        Console.WriteLine("Free Patent Read *********************")
        FPO_XmlQuery()

        While (True = True)  ' here to keep console window alive.
        End While
    End Sub

End Module
----------------------------------------------------------------------------
---------
sample of xml returned:

<?xml version="1.0"?>
<results>
<matches>1826</matches>
<query>TTL:cryogen^4.0</query>  <uspatent>
    <match>51 </match>
    <document>6722140</document>
    <title><![CDATA[ Cascade cryogenic thermoelectric cooler for cryogenic
and room temperature applications]]></title>
    <link>http://www.freepatentsonline.com/us6722140.html</link>
  </uspatent>
  <uspatent>
    <match>52 </match>
    <document>6718775</document>
    <title><![CDATA[ Dual chamber cooling system with cryogenic and
non-cryogenic chambers for ultra high vacuum system]]></title>
    <link>http://www.freepatentsonline.com/us6718775.html</link>
  </uspatent>
  <uspatent>
    <match>53 </match>
    <document>6712880</document>
    <title><![CDATA[ Cryogenic process utilizing high pressure absorber
column]]></title>
    <link>http://www.freepatentsonline.com/us6712880.html</link>
  </uspatent>
....
....
....
----------------------------------------------------------------------------
----------------------
Error message text:

Unhandled Exception: System.Net.WebException: The underlying connection was
clos
ed: The server committed an HTTP protocol violation.
   at System.Net.HttpWebRequest.CheckFinalStatus()
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.HttpWebRequest.GetResponse()
   at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials
crede
ntials)
   at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)

   at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type
ofO
bjectToReturn)
   at System.Xml.XmlTextReader.CreateScanner()
   at System.Xml.XmlTextReader.Init()
   at System.Xml.XmlTextReader.Read()
   at System.Xml.XmlReader.MoveToContent()
   at System.Xml.XmlReader.ReadStartElement(String name)
   at XMLtest2.Module1.FPO_XmlQuery() in C:\XMLtest\XMLtest2\Module1.vb:line
68
   at XMLtest2.Module1.Main() in C:\XMLtest\XMLtest2\Module1.vb:line 94



0
Q
9/28/2005 5:25:45 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
414 Views

Similar Articles

[PageSpeed] 41

What build are you using please? I transposed your code into C# and this is 
no repro for me on Whidbey RTM builds.

C:\>csc FPO_XmlQuery.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

FPO_XmlQuery.cs(17,16): warning CS0219: The variable 'urla' is assigned but 
its value is never used

C:\Documents and Settings\alexkr\My Documents\My 
Tests\Managed>FPO_XmlQuery.exe
XML tests...
Free Patent Read *********************
matches: 1827
query: TTL:cryogen^4.0
match: 51
document: 6722866
title:  Pump system for delivering cryogenic liquids
link: http://www.freepatentsonline.com/us6722866.html

.... <snipped for length> ...

match: 100
document: 6622758
title:  Interlock for cryogenic liquid off-loading systems
link: http://www.freepatentsonline.com/us6622758.html

C:\>


"Q" <Q@Q.com> wrote in message news:iv2dnQ5q1vbQT6feRVn-qA@rcn.net...
>I am feeding XmlTextReader a URL that returns the XML that then gets 
>parsed.
> The URL forms a query that affects how much data is returned in XML but 
> not
> the format of the data.
>
> The problem is that when the URL string exceeds about 163 characters
> (strange number) XmlTextReader seems to choke on it and it doesn't seem 
> like
> any XML is actually being returned and the code throws an exception on
> reading the first element.  Shorter URL strings seem to work fine. 
> Strings
> longer than ~163 chars work fine when pasted into a browser, so the server
> is returning good XML.
>
> Sorry for the long post.....
> Code, XML, error msg follow:



0
alexkr (6)
9/29/2005 4:41:05 PM
I'm using Visual Studio .NET 2003 and .NET v1.1.  As it turns out, the error
has nothing to do with XmlTextReader at all.  The problem is with the
parsing of http headers in .NET.  .Net 1.0 SP3 and .NET 1.1 SP1 tightened up
the parsing of http headers for security reasons (to block out mal-formed
headers).  KB 888527 has info about this.  The workaround is to set the
useUnsafeHeaderParsing = true in the app.config file as the knowledge-base
article states.  The "fix" is to have the XML server send clean http
headers.  It would be curious to see if the default behavior for Whidbey has
useUnsafeHeaderParsing = true.  That would be a potential security hole
(albeit, maybe a minor one.)

For me, the problem is solved....  Thanks for your response.

"Alex Krawarik [MSFT]" <alexkr@online.microsoft.com> wrote in message
news:O3yQXSRxFHA.3400@TK2MSFTNGP14.phx.gbl...
> What build are you using please? I transposed your code into C# and this
is
> no repro for me on Whidbey RTM builds.
>
> C:\>csc FPO_XmlQuery.cs
> Microsoft (R) Visual C# 2005 Compiler version 8.00.50727
> for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
> Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.
>
> FPO_XmlQuery.cs(17,16): warning CS0219: The variable 'urla' is assigned
but
> its value is never used
>
> C:\Documents and Settings\alexkr\My Documents\My
> Tests\Managed>FPO_XmlQuery.exe
> XML tests...
> Free Patent Read *********************
> matches: 1827
> query: TTL:cryogen^4.0
> match: 51
> document: 6722866
> title:  Pump system for delivering cryogenic liquids
> link: http://www.freepatentsonline.com/us6722866.html
>
> ... <snipped for length> ...
>
> match: 100
> document: 6622758
> title:  Interlock for cryogenic liquid off-loading systems
> link: http://www.freepatentsonline.com/us6622758.html
>
> C:\>
>
>
> "Q" <Q@Q.com> wrote in message news:iv2dnQ5q1vbQT6feRVn-qA@rcn.net...
> >I am feeding XmlTextReader a URL that returns the XML that then gets
> >parsed.
> > The URL forms a query that affects how much data is returned in XML but
> > not
> > the format of the data.
> >
> > The problem is that when the URL string exceeds about 163 characters
> > (strange number) XmlTextReader seems to choke on it and it doesn't seem
> > like
> > any XML is actually being returned and the code throws an exception on
> > reading the first element.  Shorter URL strings seem to work fine.
> > Strings
> > longer than ~163 chars work fine when pasted into a browser, so the
server
> > is returning good XML.
> >
> > Sorry for the long post.....
> > Code, XML, error msg follow:
>
>
>


0
Q
9/29/2005 9:36:46 PM
Reply:

Similar Artilces:

Dowload file from URL with VBA
I am trying to write a simple access program where the users can download file from internet website. I have the internet Domain and password. What function or command can be used to connect to the internet domain, so that I can have other command to access the file in the internet for dowloading. -- TS Lim You are wanting to FTP files to/from a server. Take a look at http://www.devhut.net/index.php?lang=en&pid=0000000028 -- Hope this helps, Daniel Pineault http://www.cardaconsultants.com/ For Access Tips and Examples: http://www.devhut.net Please rate this post usin...

Limit entity access by Business Unit
Hello All, Ok, this should be a simple one, but when attempting to set this up, it did not work. The structure I want to set up is the following: Root Business Unit Root Business Unit entities (contacts, cases...) 1st Sub Business Unit 1st Sub Business Unit entities 2nd Sub Business Unit 2nd Sub Business Unit entities Pretty simple, right? The permissions would be as follows: Users who belong to the root BU can see all entities throughout the system. Users who belong to a Sub BU would only have access to entities belon...

HTML Email Limitations in Outlook #2
Ive trying to establish what the limitations in HTML emails are. I've sucessfully created HTML Emails with images & Links, but want to add other HTML functionality such as auto refresh, redirect, open browser windows. I have these working in HTML pages, but not when sent as email. Are these functions possible? Is there a definitive list online of the HTML capabilities for email? Regards ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ...

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

Limiting rows & columns #2
I want to keep the far right and far left columns from scrolling off the page, I want any scrolling to be done within those fixed columns. -- k483 ------------------------------------------------------------------------ k483's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=10791 View this thread: http://www.excelforum.com/showthread.php?threadid=262965 Far left can be frozen by selecting B1(or B2 if you want top row frozen also) and Window>Freeze Panes. Far right cannot be frozen in this manner. You can set the Scrolling Area through VBA code. This sett...

Exchange Store limit
SBS 2003 SP2 with Exchange Sp2 Our server keeps dismounting Exchange - I think we have reached the 16Gb limit Are there any SBS specific info on how to increase this? Hi Sam, You need to go into regedit and create a new key, details: http://www.msexchange.org/tutorials/Explaining-Database-size-limit-changes-Exchange-2003-Service-Pack-2.html Simon sam wrote: > SBS 2003 SP2 with Exchange Sp2 > > Our server keeps dismounting Exchange - I think we have reached the 16Gb > limit > > Are there any SBS specific info on how to increase this? > ...

STM (streaming file) too big
Hi all We have just installed exchange 2003 standard and are already experiencing problems with hitting the 16Gb limit The server has only been runnning for 2 weeks! The .stm file is now over 14Gb in size even after we did an offline defrag! All users are currently running as POP3 clients and will be migrating over to MAPI integrated clients as soon as possible. Whilst i understand that the stm file contains message bodies to support non mapi clients what i dont understand is why this file remains so large after POP3 clients have downloaded all their mail. Is this by design? How ca...

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

Opportunity URL in email notification
Hi guys! I have this idea: Everytime an new ooprtunity is created, I'd like to automatically sent an email to my users. To accomplish that, I created a field in the opportunity entity called new_url (type is url). I included these 2 lines in the forms's OnSave() event: crmForm.all.new_url.DataValue = "http://crmserver/ourCRM/sfa/opps/edit.aspx?id=" + crmForm.ObjectId; crmForm.all.new_url.ForceSubmit = true; Finally, I created a workflow that sends an email with the field URL (new_url) in the body of the message. So far, so good. But when we get the email (using O...

Limitations in Trial Version
Hi, I'm using a customization (SDK) that calls the webservice http://192.168.X.X/mscrmservices/2006/crmservice.asmx to create/update contacts. This program worked well in a similar scenario, where CRM was registered. Now, I'm testing it in a 30 day trial version but the create / update functions are now throwing an exception. Are there limitants in this trial version that don't let me use the webservice? Thanks, Irene No; you can use the web service in the trial version. What exception are you getting ? "Irene Prieto" wrote: > Hi, I'm using a customiza...

Outlook cannot save the URL....
Hello On some machines all of a sudden we can't view attachments. Outlook pops up a message saying - cannot find the specified file. When I tried to save the attachment and view it to try get around this problem the following error comes up -> Outlook cannot save the URL to a file. Can't find this file. Make sure the path and file name are correct. I initially thought it was just that the attachment was incorrectly sent but logging on as myself I can view it just fine. Microsoft knowledge base states the following This problem occurs when you install Microsoft Office 2000...

increase the database size limit 16 Gb to
Hello, On an Windows 2003 SBS with Exchange server include I would like to increase the database size limit (16 Gb) to a larger size. Is it possible to do that on an Windows 2003 SBS Exchange server ? And how could i do that. Thanks JC Quirin Exchange Server 2003 SP2 introduced a 75GB limit. However, I am unsure if this applies to SBS as they are considered to be different products. Nue "jcquirin@eoc-france.fr" <jcquirineocfrancefr@discussions.microsoft.com> wrote in message news:FF6D1266-AC8C-4AD2-816D-12312E8687BB@microsoft.com... > Hello, > > On an Windows 2...

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

XMLTextWriter and XMLTextReader
I am looking for a way to open an xmltextwriter to append to an existing document. Currently I rename the existing document, then I created new one and copy over all the existing documents nodes. I would rather avoid renaming the files. These files can become quite large so I need to avoid loading an xmldocument as well. Does anyone have a pointer for me to review? Thanks in advance. I think I am going to go with this concept http://www.tkachenko.com/blog/archives/000053.html, I think it will suit my needs just fine. "amdrit" <amdrit@hotmail.com> wrote in messa...

Limiting the users who can approve quotes???
Is this possible? Thanks in advance, Jake Yes. >-----Original Message----- >Is this possible? > >Thanks in advance, > >Jake > > >. > ...

XmlTextReader; XmlException
Hi, I have MS .Net Framework v1.1.4322. I have this XML file: <?xml version="1.0" ?> <!--here there are two spaces at the beginning--> <aaa> <a id="1"> <Dept>Finance</Dept> </a> <a id="2"> <Dept>Marketing</Dept> </a> </aaa> This file opens correctly with Internet Explorer. When I try to read from it with XmlTextReader the code throws XmlException. Here is the code: XmlTextReader reader=new XmlTextReader("EmpRec.xml"); try { reader.Rea...

Basic XmlTextReader question
I shall make a make a function that will read an XML file, looking for elements like this <context id="A1"> <period> <instant>2001-01-01</instant> </period> </context> or this <context id="A2"> <period> <startDate>2001-01-01</startDate> <endDate>2001-12-31</endDate> </period> </context> Here's the code I've written so far: static string[] GetContext(string id) { XmlTextReader r = new XmlTextReader(file_document); string[] period = new string[2]; while(...

Outlook 2000 Limits
First question is this: Is there a limit to the number of events in a day within Outlook 2000? Next is: Where can I find a document that lists all of Outlook 2000s limits? TIA, Pam Pammi <Pammi@discussions.microsoft.com> wrote: > Next is: Where can I find a document that lists all of Outlook 2000s > limits? There is no such document, but a lot of information can be found in the Microsoft Knowledgebase and http://support.microsoft.com/ -- Brian Tillman ...

not getting a sapce from XmlTextReader
Hi; Using XmlTextReader when we have a node as follows (not single space): <w:t> </w:t> We do not get a node of XmlNodeType.Text or XmlNodeType.SignificantWhitespace ANy idea why and how do we force it to give us the text? We do not set WhitespaceHandling so that should be All. ??? - thanks - dave david@at-at-at@windward.dot.dot.net Windward Reports -- http://www.WindwardReports.com me -- http://dave.thielen.com Cubicle Wars - http://www.windwardreports.com/film.htm On Thu, 27 Aug 2009 17:38:59 -0600, David Thielen <thielen@nospam.nospam> wrote: >Hi; > >Usin...

URL links won't open in MS Outlook 2000 #2
When I double click on the URL link sent in an email, Outlook 2000 won't open it. I run OS Win 2000 with MS Office 2000. Does anyone knows a fix to this problem? ...

Limit records in combo box
I want a combo box (which is placed in the sub form) to display only those rows, which falls under the creiteria given in the main form Maran, It would have been helpful to include an example, so any response could be a bit more specific. You'll want to use the value of some field on the form as a criteria against that same field in your combobox query. For example... field [City] = "Boston" on a form. In the query behind the combo, against the City field, a criteria of... =Forms!frmYourFormName!City will filter the records returned in the combo to only &...

Servises Server URL
I am trying to install CRM and I get this error: Specified Reporting Services Report Server http://mars was not found. Can someone explain what the Report Server URL Is. Try http://mars/reportserver. -- Michael H�hne, Microsoft Dynamics CRM MVP Web: http://www.stunnware.com/crm2 Feed: http://www.stunnware.com/crm2/atom.aspx Custom Lookup Dialog: http://www.stunnware.com/crm2/?area=customLookup ---------------------------------------------------------- "B-Man" <motshoaneb@inkanyezirenaissance.com> schrieb im Newsbeitrag news:1170141323.052372.136710@a75g2000cwd.googlegr...

Exchange 2007 Mailbox limits
I have an Exchange 2007 server. One user is not able to receive any mail due to what appears to be a mailbox limit size issue. The NDR is: ------------------------------------------------------------------- Delivery has failed to these recipients or distribution lists: user@mydomain.com The recipient's mailbox is full and can't accept messages now. Microsoft Exchange will not try to redeliver this message for you. Please try resending this message later, or contact the recipient directly. ------------------------------------------------------------------- I checked his ...

spending limit exceeded is false & is not exceeded
Money 2004 Budget- For two months now my Budget Planner says that Bills: Cell Phone Charges spending limit is exceeded and the budgeted amount is $0. I go to Edit Budget and low and behold under Other Expenses is Bills: Cell Phone Charges with $23.42. Why is this happening? ...

Still get limit warnings after change
I have been working with my E2K3 server to enable more convienient use of the Mail message warning limit. I installed the Quota message service which works very well but when i change a users limits and/or the limits set in the ESM console (mailbox store properties) i am still getting a warning for a user who is now within limits. Is there a lag time? can i manually update something? so the user doesn't receive limit warnings anymore?? Quota changes can take up to two hours to take effect. -- Ed Crowley MVP - Exchange "Protecting the world from PSTs and brick backups!" &q...