|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi!
I have written a block of code in .asp to pull an xml file from a customers site using Msxml2.ServerXMLHTTP.4.0, which then passes the .responseBody straight into a microsoft.XMLDOM object set Nlv_Http = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0") Nlv_Http.open "GET", Nqv_XMLImportFile, false Nlv_Http.Send "" if (Nlv_Http.status <> 200 ) then ' deal with the error else Set Nlv_XML = Server.CreateObject("microsoft.XMLDOM") Nlv_XML.async = False Nlv_XML.validateOnParse = False Nlv_XML.load(Nlv_Http.responseBody) if Nlv_XML.parseError.errorCode = 0 then ...... which is working fine for 99% of feeds but I get errors with the ' character. I assumed that if I put the response straight into the load that the encoding would remain the same as the feed. The offending feed is UTF-8. Any help would be appreciated... Would also be happy if somebody called me stupid and pointed out a simple error ![]() |
|
#2
|
||||
|
||||
|
Hi and welcome to the forums!
If you are facing problems because of single quote then you can replace it. Something like Code:
Replace(strInput, "'", "'") Generally xml can break or have problems with &, <, >, " and ' So i make a function like this Code:
Function chkCharacters(strInput)
'Replace special characters from xml
strInput = Replace(strInput, "&", "&")
strInput = Replace(strInput, """", """)
strInput = Replace(strInput, "<", "<")
strInput = Replace(strInput, ">", ">")
strInput = Replace(strInput, "'", "'")
chkCharacters = strInput
End Function
|
|
#3
|
|||
|
|||
|
Hi Micky, Thanks for the reply!
Are you saying that i should change line my line to: Nlv_XML.load(ReplaceFunction(Nlv_Http.responseBody )) Will this preseve the encoding from the stream? Steve Quote:
|
|
#4
|
||||
|
||||
|
Well, you can try it and see if it works
|
|
#5
|
|||
|
|||
|
Hi Micky,
I think it is actually my customer who has encoded their stream incorrectly; spent many hours looking at what they are sending and it looks as though they have not encoded text in one tag in the same way as they have in another; lots of cutting and pasting in a 4MB XML file and it now works. BTW using replace on the HTTP response stream did not work as Replace didn't like a stream as imput. Thanks for the quick responses. Steve Quote:
|
|
#6
|
||||
|
||||
|
Glad you got it working.
I also wasnt sure about Replace.......... anyway, thanx for sharing the solution ![]() |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > VBScript - General - Question - Problems Parsing XML from an HTTP response |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|