Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 25th, 2008, 08:54 PM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can not load XML

I am getting below Error whem I am tryin to process below code :

Can not load XML: A string literal was expected, but no opening quote character was found


 
Quote:
quote:
Quote:
<%

Call consumeWebService

Sub consumeWebService

    Dim webServiceUrl, httpReq, node, myXmlDoc

    webServiceUrl = "http://www.clearmybaddebt.com/debt/reports/generateLeadID.asp?FirstName=TOM&LastName=SCOTT&Ci ty=MIAMI&State=FL&Phone=7863267522&LeadCreationDat e=5/16/2008&TotalDebtAmount=13000&internalLeadID=19721&Le adCreationDate=5/16/2008"

    Set httpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")

    httpReq.Open "GET", webServiceUrl, False
    httpReq.Send
    dpXML = httpReq.ResponseText
    Set myXmlDoc =Server.CreateObject("MSXML2.DomDocument.3.0")
    myXmlDoc.async = False
    myXmlDoc.validateOnParse = False
    myXmlDoc.resolveExternals = False
    myXmlDoc.load(httpReq.responseBody)
    Set httpReq = Nothing
    If not myXmlDoc.LoadXml(dpXML) Then
    ErrorMessage = "Can not load XML:" & vbCRLF & myXmlDoc.parseError.reason & vbCRLF & ErrorMessage
    Response.write ErrorMessage
    Response.write dpXML
    End If
    Set httpReq = Nothing ' clear HTTP object
    Set RSSItems = myXmlDoc.getElementsByTagName("ErrorDescription")
    RSSItemsCount = RSSItems.Length-1
    Set myXmlDoc = Nothing ' clear XML
    For i = 0 To RSSItemsCount
       Set RSSItem = RSSItems.Item(i)
    for each child in RSSItem.childNodes
    Select case lcase(child.nodeName)
        case "ErrorDescription"
            Response.write child.text
            Response.write ErrorMessage
    End Select
    next
     next

End Sub

%>


I am also getting an Error :

Can not load XML: End tag 'HEAD' does not match the start tag 'META'.


ErrorMessage = "Can not load XML:" & "<br>" & xmlDOM.parseError.reason & "<br>" & "ErrorCodce-" & xmlDOM.parseError.errorCode & "<br>" & "Error Line Number-" & xmlDOM.parseError.LINE

Above line Returns me :


Quote:

Can not load XML:
End tag 'HEAD' does not match the start tag 'META'.
ErrorCodce--1072896659
Error Line Number-11


Line 11 is :

Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

Is this Line 11 of ASP Code or Line 11 f XML document ?

Reply With Quote
  #2 (permalink)  
Old May 26th, 2008, 03:45 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

>Can not load XML: A string literal was expected, but no opening quote character was found

Well, that's pretty clearly saying that something is wrong with your XML, not with your ASP code, so why are you showing us your ASP code amd not your XML?

>Can not load XML: End tag 'HEAD' does not match the start tag 'META'.

That looks very much as if the "XML" you are trying to load is not XML at all, but HTML.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old May 26th, 2008, 03:54 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

... which could point to the file being served as HTML rather than text/xml, i.e. the wrong content type is being set on the server.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #4 (permalink)  
Old May 26th, 2008, 04:19 AM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the File I am being shown as XML :

Quote:
quote:
<?xml version="1.0" encoding="utf-8" ?>
- <returnMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns=http://www.abcsite.com/>
<ErrorName>Lead Import Error.</ErrorName>

<ErrorDescription>Invalid Login Attempt. Your lead has not been imported. Please review system documentation for required fields and data types. For further help please call xxx-xxx-xxxx.</ErrorDescription>

<LeadID />

<ClientAvailable>true</ClientAvailable>

</returnMessage>

Reply With Quote
  #5 (permalink)  
Old May 26th, 2008, 04:24 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well to be honest that's obviously not the XML that is returned causing the second error is it - it doesn't contain either an HTML or META element. That error is likely caused when an error page is returned by the web service you are calling.


As for this one - there appears to be quotes missing from around the xmlns=http://www.abcsite.com which should be xmlns="http://www.abcsite.com". I don't know if that is a cut and paste error or not.



/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #6 (permalink)  
Old May 26th, 2008, 04:27 AM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Server which returns me XML, C# Instructions which can be used to get back HTML instead of XML:
************************************************** *******************

Quote:
quote:


ABCSite.InsertLeads tsRealTimeWS = new ABCSite.InsertLeads();
ABCSite.returnMessage tsReturnWS = new ABCSite.returnMessage();

tsReturnWS = tsRealTimeWS.InsertLead(
Request.Form["txtSupplierID"],Request.Form["txtSupplierPassword"], Request.Form["txtFirstName"], Request.Form["txtLastName"],
Request.Form["txtCoAppFirstName"], Request.Form["txtCoAppLastName"],
Request.Form["txtCity"], Request.Form["txtState"], Request.Form["txtPostalCode"], Request.Form["txtHomePhone"], Request.Form["txtWorkPhone"], Request.Form["txtWorkPhoneExt"], Request.Form["txtBestCallTime"], Request.Form["txtEmailAddress"], Request.Form["txtOriginalLeadDate"],Request.Form["txtExternalLeadID"], Request.Form["txtIPAddress"], Request.Form["txtExtraFields"]);

lblWSResponse.Text = tsReturnWS.ErrorName + " " + tsReturnWS.ErrorDescription;
Asked to use Instructions from below page to design C# page

http://www.sitepoint.com/article/net...rvices-5-steps
Reply With Quote
  #7 (permalink)  
Old May 26th, 2008, 04:29 AM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Sorry, Its a CUT and PASTE Error :

It should be "www.abcsite.com/"


Instruction in Server Document :

Quote:
quote:

HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.

POST /Suppliers/WebServices/InsertLeads.asmx/InsertLead HTTP/1.1
Host: apps.abcsite.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

SupplierID=string&SupplierPassword=string&FirstNam e=string&LastName=string&EmailAddress=string&CoApp FirstName=string&CoAppLastName=string&Address=stri ng&City=string&State=string&PostalCode=string&Home Phone=string&WorkPhone=string&WorkPhoneExt=string& CurrentEmployer=string&YearsThere=string&Income=st ring&BestCallTime=string&OriginalLeadDate=string&E xternalLeadID=string&IPAddress=string&ExtraFields= string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<returnMessage xmlns="http://www.abcsite.com/">
  <ErrorName>string</ErrorName>
  <ErrorDescription>string</ErrorDescription>
  <LeadID>string</LeadID>
  <ClientAvailable>boolean</ClientAvailable>
</returnMessage>

Reply With Quote
  #8 (permalink)  
Old May 26th, 2008, 04:36 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

As suggested previously you need to add:
Code:
Response.ContentType = "text/xml" before returning the content. You can add this in code or using the ContentType attribute in the aspx file.
--

Joe (Microsoft MVP - XML)
Reply With Quote
  #9 (permalink)  
Old May 26th, 2008, 04:40 AM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default


I have to add

Response.ContentType = "text/xml"

in my above ASP Code, not asmx ?

Reply With Quote
  #10 (permalink)  
Old May 26th, 2008, 04:42 AM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/xml/MyXML.asp, line 15, column 14
Set xmlDOM =Server.CreateObject("MSXML2.DomDocument.3.0")
-------------------------------------------^


Reply With Quote
Reply


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
Can I load this xml to a dataset? chepla C# 2005 1 August 11th, 2008 08:51 AM
load XML issue AbrarNazeer XML 5 March 13th, 2008 09:43 AM
Load Xml From String ffbalota J2EE 0 January 24th, 2004 06:30 PM
Load Xml From String ffbalota JSP Basics 0 January 24th, 2004 06:29 PM
Load Xml From String ffbalota Apache Tomcat 0 January 24th, 2004 06:28 PM



All times are GMT -4. The time now is 09:06 AM.


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