responseTextには、値が設定されているのにresponseXMLに値が設定されて
いないのはなぜでしょうか?
原因として何が考えられるでしょう?
↓↓↓<実行モジュール>↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
Dim domDoc As New MSXML2.DOMDocument
Dim domDoc2 As NEW MSXML2.DOMDocument
Dim xmlHttp As New MSXML2.XMLHTTP
If Not domDoc.Load("D:Sample.xml") Then
Exit Sub
End If
xmlHttp.open "POST", "http://localhost/sample/sample01.jsp", False
xmlHttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
xmlHttp.setRequestHeader "Content-Length", Len(domDoc.xml)
xmlHttp.send doc.xml
If xmlHttp.Status <> 200 Then
MsgBox "Error :" & xmlHttp.Status & " " & xmlHttp.statusText
Exit Sub
End If
Set domDoc2 = xmlHttp.responseXML
RichTextBox1.Text = xmlHttp.responseText
RichTextBox2.Text = retXml.xml
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
サーバから返される Content-Type と Charset を確認してみてください。
回答ありがとうございました。
ただ、私の知識不足で回答いただいた内容の意味がよくわかりません。
サーバ側にどのような設定がされていればよいのでしょうか?
> サーバ側にどのような設定がされていればよいのでしょうか?
具体的な設定方法はサーバの種類によって異なりますので、
詳しくは書きませんが、要は responseXML プロパティの解説に
http://msdn2.microsoft.com/en-us/library/ms757055.aspx
If the response was generated by an ASP page and the MIME type was not correctly set to "text/xml" or "application/xml" using the ASP method Response.ContentType, responseXML will be empty.
……と書かれているように、Content-Type として、適切な MIME タイプが
設定されていなければ、プロパティの中身が空になってしまうという事です。
ツイート | ![]() |