[XML/ASP/SQL] Encoding-type xml

Pagina: 1
Acties:

  • 1liter
  • Registratie: Maart 2004
  • Laatst online: 18-05-2021

1liter

appelsap

Topicstarter
Vanaf de klant (vanuit een DLL) wordt er een xml-bestand naar de server gestuurd middels MSXML2.xmlHttp
code:
1
2
3
Call xmlHttp.open("POST", m_WebsiteUrl, False) 
xmlHttp.setRequestHeader "Content-Type", "text/xml; charset=windows-1252" 
Call xmlHttp.send(xmlDom.xml)


De code op de server om de xml op te halen is:
code:
1
2
3
4
5
set xmldoc = Server.CreateObject("Microsoft.XMLDOM") 
xmldoc.async=false 
xmldoc.validateOnParse = False ' Added line ********** 
xmldoc.resolveExternals = False ' Added line ********** 
xmldoc.load(request)


request bevat:
code:
1
2
3
4
5
6
7
8
9
10
11
<?xml version="1.0"?> 
<SITEMANAGER> 
<CONTENT> 
<AREA ID="-1"> 
<![CDATA[ 
Xcvdâ€fvdf†
DfgdfÃ&uml; 
]]> 
</AREA> 
</CONTENT> 
</SITEMANAGER>


Na het veranderen van de processinginstruction-node door:
code:
1
2
Set oProcess = xmldoc.createProcessingInstruction("xml", "version=""1.0"" encoding=""windows-1252""") 
xmldoc.ReplaceChild oProcess, xmldoc.childNodes(0)

Ziet de xml er nu als volgt uit (en dit is hoe het zou moeten zijn):
code:
1
2
3
4
5
6
7
8
9
10
11
<?xml version="1.0" encoding="windows-1252"?> 
<SITEMANAGER> 
<CONTENT> 
<AREA ID="-1"> 
<![CDATA[ 
Xcvd"fvdf"
Dfgdfè 
]]> 
</AREA> 
</CONTENT> 
</SITEMANAGER>

Vervolgens stoppen wij de code van de AREA-node in de DB:
code:
1
2
3
For each childnode in xmlDoc.selectSingleNode("SITEMANAGER/CONTENT").childNodes 
Insert(childnode.text) 
Loop


De code (ASP) voor het toevoegen aan de DB is:
code:
1
2
3
4
5
6
Function Insert(m_Text) 
cmd.CommandText = "SM_Content_Insert" 
response.write m_text 'the text is here still as it should be 
cmd.Parameters("@Text") = m_Text 
cmd.Execute() 
End Function

Wanneer ik kijk in SQL Profiler dan zie ik dat de tekst weer verandert is naar wat het was

Het veld in de DB is een [text] veld (geen ntext)

De Stored Procedure is:
code:
1
2
3
4
5
6
CREATE PROCEDURE SM_Content_Insert 
@Text text, 
AS 
INSERT INTO 
SM_Content ([Text]) 
VALUES (@Text)


Vervolgens wordt dit getoond op een website.

Kan iemand mij helpen om dit op te lossen. Waar zit mijn denk-fout?

[ Voor 12% gewijzigd door 1liter op 19-08-2004 14:41 ]

1liter