I have this VBScript but it won't run since it keeps coming up with the error "XML must have top level element." Where is this error? I'm not very familiar with VBScript so if you could help in layman's terms it would be helpful.
DIM oXMLHTTP
DIM oXMLDoc
function ProcessSend()
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
oXMLHTTP.onreadystatechange = getRef("HandleStateChange")
'strEnvelope = "username=user&password=pass"
strEnvelope="<?xml version=""1.0"" encoding=""utf-8""?>"&_
"<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"" s:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">"&_
"<s:Body>"&_
"<u:X_SendKey xmlns:u=""urn:panasonic-com:service:p00NetworkControl:1"">"&_
"<X_KeyEvent>NRC_MUTE-ONOFF</X_KeyEvent>"&_
"</u:X_SendKey>"&_
"</s:Body>"&_
"</s:Envelope>"
'call msgbox(strEnvelope)
call oXMLHTTP.open("POST","http://192.168.2.93:55000",false)
call oXMLHTTP.setRequestHeader("User-Agent:","Panasonic iOS VR-CP UPnP/2.0")
call oXMLHTTP.setRequestHeader("Host:","192.168.2.93:55000")
call oXMLHTTP.setRequestHeader("Content-Type:","text/xml; charset=""utf-8""")
call oXMLHTTP.setRequestHeader("SOAPACTION:","""urn:panasonic- com:service:p00NetworkControl:1#X_SendKey""")
call oXMLHTTP.setRequestHeader("Content-Length:","331")
call oXMLHTTP.send(strEnvelope)
end function
Sub HandleStateChange
if(oXMLHTTP.readyState = 4) then
dim szResponse: szResponse = oXMLHTTP.responseText
call oXMLDoc.loadXML(szResponse)
if(oXMLDoc.parseError.errorCode <> 0) then
'call msgbox("ERROR")
response = oXMLHTTP.responseText&" "&oXMLDoc.parseError.reason
call msgbox(oXMLDoc.parseError.reason)
else
Set prodList = oXMLDoc.getElementsByTagName("ns2:listAllProductInformationResponse")(0).childNodes
for each prod in prodList
productText = productText &" "& prod.getAttribute("eanCode") & ";"&prod.getAttribute("productCode")&";"&prod.getAttribute("availability") &"#"& vbcrlf
next
'productText = productText & " "
set fx=CreateObject("Scripting.FileSystemObject")
set x=fx.CreateTextFile("C:\pioneerLIST.txt",true)
x.WriteLine productText
x.Close
set x=nothing
set fx=nothing
end if
end if
End Sub
processSend()
</script>
</job>
Can you share your XML ? from your code it contains only XML XSD deceleration w/oa root element (make sure to have in your XML primary root element which all the elements are decedents of it)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.