How do I load the XML got by HttpWebResponse read into a StreamRea

Hi, 

I would like to know like How do I load the XML Response which I got from 
HttpWebResponse? 

What I am doing, I will just put for your perusal;

Dim hwrRequest As HttpWebRequest = 
CType(HttpWebRequest.Create("https://someurl"), HttpWebRequest)
        
        hwrRequest.Method = "POST"
        hwrRequest.ContentType = "text/xml"

        Dim encoding As UTF8Encoding = New UTF8Encoding
        Dim postBytes() As Byte = encoding.GetBytes(strReq)

        hwrRequest.ContentLength = postBytes.Length

        Dim postStream As Stream = hwrRequest.GetRequestStream()
        postStream.Write(postBytes, 0, postBytes.Length)
        postStream.Close()


        Dim hwrResponse As HttpWebResponse = CType(hwrRequest.GetResponse(), 
HttpWebResponse)
        Dim responseStream As Stream = hwrResponse.GetResponseStream()
        Dim sr As StreamReader = New StreamReader(responseStream)
        Dim respString As String = sr.ReadToEnd()




        ''Me.TextBox1.Text = respString

'' here If I am populating in the Multiline Textbox , I am getting the XML 
Response

But What I want is directly consume that XML Response into the DOM 
XmlDocument.

I tried passing the StreamReader  into the Load Method of XmlDocument, but 
it gives me the error.

        Dim xDoc As New XmlDocument
        xDoc.PreserveWhitespace = True
        xDoc.Load(respString)
        AddText("XML Content", xDoc.OuterXml)

        hwrResponse.Close()

Any help would be of great help to me

bye
ss
0
SS (61)
5/24/2006 2:21:02 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
640 Views

Similar Articles

[PageSpeed] 48

The Load method of XmlDocument states

[Visual Basic]
Overloads Public Overridable Sub Load( ByVal inStream As Stream )

Therefore perhaps see if you can just use:
xDoc.Load(hwrResponse.GetResponseStream())

Let us know if this works !

However I think there is an error in your code shown
>        xDoc.Load(respString)

when I think you meant to say
xDoc.Load(sr)

Dickster

0
gdick (75)
5/25/2006 9:03:37 AM
Hi,

Thanks for your reply. I tried that, but it is giving the error like below

The root element is missing. 
Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information about 
the error and where it originated in the code. 

Exception Details: System.Xml.XmlException: The root element is missing.

Source Error: 


Line 187:        Dim xDoc As New XmlDocument
Line 188:        xDoc.PreserveWhitespace = True
Line 189:        xDoc.Load(hwrResponse.GetResponseStream())
Line 190:        AddText("XML Content", xDoc.OuterXml)
 
bye
ss

"dickster" wrote:

> The Load method of XmlDocument states
> 
> [Visual Basic]
> Overloads Public Overridable Sub Load( ByVal inStream As Stream )
> 
> Therefore perhaps see if you can just use:
> xDoc.Load(hwrResponse.GetResponseStream())
> 
> Let us know if this works !
> 
> However I think there is an error in your code shown
> >        xDoc.Load(respString)
> 
> when I think you meant to say
> xDoc.Load(sr)
> 
> Dickster
> 
> 
0
SS (61)
5/29/2006 5:48:01 AM
Reply:

Similar Artilces:

Export contacts in XML
I would like to export my contacts from Outlook express in a xml's file. I know if possibile to export in CSV than convert with excel to xml, but what I would like do it with a single step. I've looked for 3D part sw, but I haven't results, TIA -- Max Art2009;109587 Wrote: > I would like to export my contacts from Outlook express in a xml's > file. > I know if possibile to export in CSV than convert with excel to xml, > but > what I would like do it with a single step. > I've looked for 3D part sw, but I haven't results, Thi...

Passing XML via linked server
When I execute the following stored procedure it should return XML output. EXEC SALES.customer_db.dbo.spILD_homepage_sel '<homepage catid="777"> <billingcustid>777</billingcustid> </homepage>' It works fine on the SALES (local) server. I get something like: XML_F52E2B61-18A1-11d1-B105-00805F49916B <status>Invalid homepage info specified.</status> But when I call it from the BILLING server (where SALES is set up as a linked server), I get hexidecimal output like: XML_F52E2B61-18A1-11d1-B105-00805F49916B 0x44004406730074006100740...

Read File Properties
How would I read the file version properties of a standard DLL? In particular I need the company name property from VISA32.dll. VISA32.dll is a standardized Virtual Instrumentation Software Architecture function library that is published by several manufacturers. I need the manufacturer name of the *installed* library. David "David Youngblood" <dwy@flash.net> wrote in message news:%23oPqMidaKHA.4668@TK2MSFTNGP06.phx.gbl... > How would I read the file version properties of a standard DLL? In > particular I need the company name property from VISA3...

loading network card information ...error provider load failure
This is a multi-part message in MIME format. ------=_NextPart_000_000F_01CA7D92.03F9F310 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi there, I get "loading network card information ...error provider load failure" = when I go and use systeminfo.exe . How can I fix this? Thanks, Gordon ------=_NextPart_000_000F_01CA7D92.03F9F310 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN&qu...

OWA (Not Loading)
Does anyone know of any issues with Satellite Service and the right side of OWA not loading. The left side loads but the user cannot see anything on the right. OWA works from any other connection. Thanks, KG ...

SOS,how to load a invalid or damaged .gif file to create Image Object.
hi everyone. my question is this:how to load a .gif image file that is invalid or damaged image format? Notice,I want to load the invalid damaged image file to operate it. my code is below,but all of they are not correct. -------- 1.Image.FromFile(fileName);load from a file directly,it throws a OutOfMemoryException.In msdn,it's mean the file is a invalid image format. 2.Image.FromStream(stream);load from stream,it throws a ArgumentException. -------- ps:IE and Google Picasa can load and display the damaged .gif file correct. Or there is any other methods to operate the i...

Error loading CRM 3.0 Client with Outlook
I receive error message "An error occurred loading Microsoft CRM Functionality" when starting Outlook with CRM 3.0 client installed. I have uninstalled CRM, Office, and cleaned the register using Register Mechanic. I am now getting the same error with an event error "A problem occurred initializing Microsoft CRM COM interopt". Anyone have any ideas? Thanks. I have the exact same issue has anyone found a solution to this? I am running all avialable updates on both Office 2003 and XP Pro, I DO NOT have the Business Contact Manager for Outlook installed. "rtop...

Not notifying when message read
The checkmark in Tools - Options - Email Options - Tracking Options - Read receipt is checked but I do not always get a read receipt, just occasionally. Is there anything else I need to check? Thanks. No, note that a read receipt requires interaction of the receiver and must be supported by both the receiving client and the mailservers. -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -Creating Signatures -Create an Office XP CD slipstreamed with Service Pack 3 ----- "Paula" <anonymous@discussions.microsoft.com> wrote in message news:1c0b30...

Read messages marked unread
I have Windows 7 and WLMail. Sometimes I find that newsgroup messages that I have read show up as unread again when I go back to retrieve more messages. For example I read all the new messages in this group up to 20:00 yesterday. Today at 13:30 forty of those messages are shown as unread. This can happen with other newsgroups not just those on microsoft.public. Sometimes several days pass without this happening. I have a suspicion that it may coincide with messages appearing in recovered items. No one else I have spoken to has seen this behaviour. It's not a great annoya...

XPath XML Statement Creator
Does anybody know of an application that will dynamically generate XPath statements. Basically, I would use the program to click through the nodes of an XML file, and then have some way to generate the XPath. I have looked at Stylus Studio, but it is too pricey for just that one feature. Thanks! Derek Derek Hart wrote: > Does anybody know of an application that will dynamically generate XPath > statements. Basically, I would use the program to click through the nodes of > an XML file, and then have some way to generate the XPath. I have looked at > Stylus Studio, but it ...

loading web application project suddonly takes 5 mintues and says "Contacting server to open Web project.." wile it takes 5 minutes to load. how to fix? i tried reregistering asp.net and iisreset. no
loading web application project suddonly takes 5 mintues and says "Contacting server to open Web project.." wile it takes 5 minutes to load. how to fix? i tried reregistering asp.net and iisreset. no progres. ...

What do I load ?
Hello. I'm trying to develop a web comsuming client using VS.NET 2003(VB), .NET Framework 1.1.4322, ASP.NET 1.1.4322, WSE2.0 on a WinXP Pro Sp2 comuter. If i comsume this web service: https://xatanet.net/xatanetwebservice/tripexportservice.asmx and do this operation: RetrieveArchivedTrips using: Dim strDate As Date = "2006-04-01" Dim endDate As Date = "2006-04-28" proxy.RetrieveArchivedTrips(strDate, endDate) What do I load when i use the following statements in my program: Dim doc as XmlDocument = new XmlDocument() doc.Load() Any...

How to populate a dataset from an XML formated String
Hi there Here's my question : I'd like to populate a dataset from an XML string, ie: Dim sXmlString As String sXmlString = "<root type='E-Form'><question label='This is my first question'></question><question label='This is my second question'></question></root> Any idea to achieve this ? Thanks in advance, J.Philippe Sure... :) Take a look at the System.IO.StringReader and the DataSet.ReadXml Method.. Source code is from the following link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/h...

Debug image fails to load.
Hi, I created an OS design with KITL, Kernel debugger enabled in Debug mode. But when i try to load the image to the CEPC it fails to boot. I am attaching the log here. ------ SERIAL PORT LOG starts ----------- Microsoft Windows CE Ethernet Bootloader Common Library Version 1.0 Built Dec 9 2002 18:35:13 Copyright (c) 2000-2001 Microsoft Corporation Microsoft Windows CE Ethernet Bootloader 3.3 for CE/PC (Feb 6 2003) Boot Args @ 0x1F136 and ucLoaderFlags is 1 PCI Device Configurations (3 PCI bus(es) present)... ======================================================== Bus, Devi...

XML datatype to columned dataset
Greetings! Give a column of XML datatype containing this: <Foo> <Name>Bob</Name> <Area>Ghana</Area> <Interest>Polar Hiking</Interest> </Foo> How do I write SQL that will produce a data set (DYNAMICALLY)? Name Area Interest ----------------------------- Bob Ghana Polar Hiking The idea is that the name of the elements in my XML are untyped, and may change. But I'd like a dynamic query to handle this mapping. Thanks for your time. Dan. Daniel Bass wrote: > Give a column of XML datatype containing this: >...

Click on a link and a picture loads in cell depending on which link you have clicked
Hello If I have five links in cells A1:A5 with peoples names. How can get... e.g. If I click on Bill in A2 then a picture of Bill loads in cell D1 an then click Mark and a picture of Mark loads in D1. Thanks in advanc -- Message posted from http://www.ExcelForum.com I'm not sure what you mean by link in A1 through A5, but I'd try it this way: Put all 5 pictures on the worksheet and position them where you want them. Name them to match the values in A1:A5. Select the picture for Bill and then type Bill in the name box (to the left of the formulabar) and hit enter. After all 5...

Loading Error
Hi I am logged on as Domain administrator and have installed Office 2000 twice over.. I am getting the following error, and I have put it into Microsoft Support but it comes up with nothing. The error is "Unknown Error 0xAF54011D You Do not have permission to log on" any Ideas thanks It helps telling where you get this error and where you are trying to connect to. -- Roady [MVP] www.howto-outlook.com Tips of the month: -Setting Permissions on a Mailbox -Create an Office XP CD slipstreamed with Service Pack 3 ----- "News" <sasa@sdfad.com> wrote in message ...

Ev�nements Load et Unload
Quelqu'un peut-il me dire pourquoi je n'arrive pas � s�lectionner les �v�nements Load et Unload dans la partie droite de mon UserForm (et ce qu'il faut faire). (Je n'ai pas d'�v�nements Load et Unload dans la partie droite de ma liste, la partie gauche ayant le nom UserForm). D'avance merci, Jean-michel ...

While loading
I want to show a welcome screen while the application loads in the back ground. How can this be done? Thanks. Jess look at this:- http://www.codeproject.com/dialog/dialogspl.asp -- Vipin Aravind http://www.explorewindows.com "Jessica Weiner" <jessica@gmail.com> wrote in message news:jA8Qf.44094$F_3.26672@newssvr29.news.prodigy.net... >I want to show a welcome screen while the application loads in the back >ground. How can this be done? > > Thanks. > Jess > PJ's website has a nice class for this... obviously if you Google "Splash Scree...

Passing XML to webservice
I have a customer who wants to send us a XML message like this: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <PurchaseOrder xmlns="http://tempuri.org/"> <OrderHeader> <PONumber>10464</PONumber> </OrderHeader> <OrderDetails> <ItemNumber>63434</ItemNumber> <NumberOfItems>6</NumberOfItems> </OrderDetails> </PurchaseOrder> </SOAP-ENV:Body> </SOAP-ENV:En...

Drop-down lists loading
Hi, I have several huge drop-down lists (countries for several forms,applications etc.) to load into the CRM. The only way to do that, I found is manual typing. Any ideas how I can do that in the automatic way? Thanks. You could use the SDK to do it programatically. How long is the list? Problem is by the time you have written the code to do such a job you usually could have typed the data in. "innab" <innab@nur.com> wrote in message news:0ca201c36bcf$1629b420$a401280a@phx.gbl... > Hi, > I have several huge drop-down lists (countries for several > forms,applicat...

XSD, complexTypes, SQLXML bulk load: What am I missing?
Hello Techies-- I am reading an XML document with many nested elements. Many of these elements go to such a variety of tables, that I am trying to simply the read of the document by dumping the data into a single table using SQLXML/BulkXMLLoad. I have triggers set on an insert of this table to cascade inserts to the appropriate myriad of other tables. Originally I tried to use simpleType, then I tried to use: complexType, mixed="true" when setting up the schema, but received errors from SQLXML stating that mixed type cannot be used. The bottom line: For every level of sequenced ele...

File permissions on Excel Workbook -- make only owner/admin read/w
I would like to make my Excel Workbook writeable only to the owner of the book and the admin. I would like the workbook to be only readable to everyone else (no writing). If a user copies the workbook, that's ok. But then that new copy would be owned by the person copying it... and then only they and admin can write it. I don't want to handle this with VBA. I want this to happen when the user opening the workbook disables macros. Can you help? Thank you, Janet Apply the appropriate passwords in, Save As, Tools, General Options. Janet Panighetti wrote: &g...

OWA not loading
On E2K, while using OWA (after login), It’s getting stuck on “Loading” screen. What could be wrong? TIA Try this: http://support.microsoft.com/?kbid=280823 -- Neil Hobson Exchange MVP For Exchange news, links, and tips, check: http://www.msexchangeblog.com "Sam" <Sam@discussions.microsoft.com> wrote in message news:A25FA6E8-1560-4969-9494-44BB7FA54936@microsoft.com... > On E2K, while using OWA (after login), It's getting stuck on "Loading" > screen. What could be wrong? > TIA > ...

Excel files are 'read only' when accessed over network.
How do I make them accessible please. Also I cannot get access to Windows folder via network. Ideally I would like to get access to everything over the network if I need to. I have ticked sharing and security boxes. Since these are network drives, you may want to have your IT folks look at it and see if you have access to the drives/folders you need. gracenote wrote: > > How do I make them accessible please. > > Also I cannot get access to Windows folder via network. Ideally I > would like to get access to everything over the network if I need to. > I have ticked sharing...