469,309 Members | 2,786 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,309 developers. It's quick & easy.

XML: a string literal was expected, but no opening quote character was found.

Hi,


I am using technology:ASP with backend: sql server

I'm trying to get the sql query results in XML on my asp page, after a while or so, but i get an alert box saying

XML: a string literal was expected, but no opening quote character was found.

Any help, guidance, suggestion or solution will be greatly appreciated!

Thanks in advance,

Sush
Feb 28 '07 #1
8 26150
dorinbogdan
839 Expert 512MB
If this thread is not helpful please reply.
Feb 28 '07 #2
dorinbogdan
839 Expert 512MB
Also, check the XML to have always the attribute values quoted.
See this link.
Feb 28 '07 #3
Also, check the XML to have always the attribute values quoted.
See this link.

I have checked the quotes around the attributes in the XSL and they are all fine. So that doesn't seem to be the problem
Mar 2 '07 #4
dorinbogdan
839 Expert 512MB
How do you load the XML file or string?
Please include some sample code and XML data.
Mar 2 '07 #5
How do you load the XML file or string?
Please include some sample code and XML data.

ok, here is code, i have only removed "Get form variables" lines of code
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Response.Buffer = true
  3. Response.Expires=-1444
  4. Response.CacheControl = "no-cache"
  5. Server.ScriptTimeout=10000
  6. Response.CharSet="windows-1252"
  7. Response.ContentType="text/xml"
  8.  
  9. Dim oXMLOutput,oElement,oRs,oCn,iCount,sValue, sCols, iArrayCount, bExists, bLogonPracticeExists
  10.  
  11. Set oCn = server.CreateObject("ADODB.Connection")
  12. Set oRs = server.CreateObject("ADODB.Recordset")
  13. set oXMLOutput=server.CreateObject("MSXML2.DOMDocument")
  14.  
  15. 'connect to the database
  16. oCn.Open Application("gsConnection")
  17.  
  18. 'fetch all the records into the recordset
  19. set oRs=oCn.Execute("gs_get_riskoverview_revised '" & sCriteria & "','" & sData & "','" & sNT_ID & "','" & sStage & "','" & dtStart & "','" & dtEnd & "'")
  20.  
  21. 'sPage name is passed from the corresponding pages from where this page is called through XMLHTTP
  22.  
  23. select case sPage
  24.  
  25. case "Overview"
  26.  
  27. sCols="CURRENT_STAGE,SORT_STAGE,SALES_PROSPECT_CODE,PARTNER_NAME,MANAGER_NAME,RAF_STATUS,LATEST_RAF,COMBINED_OVERALL_RISK,RESEND,ACTIONS"
  28.  
  29. sCols=split(sCols,",")
  30.  
  31. end select
  32.  
  33. 'load the dom object
  34. oXMLOutput.loadXML("<ROWS/>")
  35.  
  36. 'used for inserting an attribute which is not present in the database
  37. bExists=0
  38.  
  39. 'used for checking the existence of logon users practice
  40. bLogonPracticeExists=0
  41.  
  42. do while not oRs.EOF
  43.     Set oElement = oXMLOutput.createElement("ROW")
  44.     oXMLOutput.selectSingleNode("//ROWS").appendChild oElement
  45.     for iArrayCount=lbound(sCols) to ubound(sCols)
  46.         for iCount=0 to oRs.Fields.Count-1
  47.             if sCols(iArrayCount)=oRs.Fields(iCount).Name then
  48.                 if oRs.Fields(iCount).Value=NULL or IsNull(oRs.Fields(iCount).Value) then
  49.                     sValue=""
  50.                 else
  51.                     sValue=oRs.Fields(iCount).Value
  52.                 end if
  53.                 oElement.setAttribute oRs.Fields(iCount).Name,sValue
  54.                 bExists=1
  55.                 exit for
  56.             end if
  57.         next
  58.         if bExists=0 then
  59.             oElement.setAttribute sCols(iArrayCount),""
  60.         end if
  61.         'reset
  62.         bExists=0
  63.     next
  64.  
  65.     'check if the logon user practice is present in the recordset
  66.     'if no then add it in the xml string    
  67.     if sPage="PracticeLoc" or sPage="PracticeGlob" then
  68.         if oRs("UNIT_CODE")=sPracticeCode then
  69.             bLogonPracticeExists=1
  70.         end if
  71.     end if
  72.     oRs.MoveNext
  73. loop
  74.  
  75. 'if the flag bLogonPracticeExists=0 then the recordset has not retrieved 
  76. 'the logon users practice hence added it to the xml string
  77. if (sPage="PracticeLoc" or sPage="PracticeGlob") and bLogonPracticeExists=0 then
  78.     Set oElement = oXMLOutput.createElement("ROW")
  79.     oXMLOutput.selectSingleNode("//ROWS").appendChild oElement
  80.     oElement.setAttribute "UNIT_CODE",sPracticeCode
  81.     oElement.setAttribute "UNIT_NAME",sDescription
  82. end if
  83.  
  84. %>
  85. <?xml version="1.0" encoding="windows-1252"?>
  86. <%
  87. Response.Write oXMLOutput.xml
  88.  
  89. set oXMLOutput=Nothing
  90. set oCn=Nothing
  91. set oRs=Nothing
  92. %>
  93.  
Mar 5 '07 #6
dorinbogdan
839 Expert 512MB
Just for test, try to remove the line (the header should be already set):
Expand|Select|Wrap|Line Numbers
  1. %>
  2. <?xml version="1.0" encoding="windows-1252"?>
  3. <%
  4.  
If no success, check carefully the formatting of oXMLOutput.xml string to be correct, because the server is not always adding quotes around the attributes.
Mar 5 '07 #7
dorinbogdan
839 Expert 512MB
Hi,
Did you succeed to solve the problem ?
If yes, please let me know, in order to close the thread.
Thanks,
Dorin.
Mar 21 '07 #8
Hi,
Did you succeed to solve the problem ?
If yes, please let me know, in order to close the thread.
Thanks,
Dorin.
No, I haven't been able to resolve this, the error occurs only when the number of rows returned by the sql query is more.
Dec 6 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by Mike | last post: by
2 posts views Thread by Robert M. Gary | last post: by
4 posts views Thread by Guadala Harry | last post: by
3 posts views Thread by Jerome Cohen | last post: by
7 posts views Thread by Jonny | last post: by
9 posts views Thread by somenath | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.