Javascript 如何从xml模式中读取元素值?
我有以下响应,我想使用javascript只读success元素:Javascript 如何从xml模式中读取元素值?,javascript,xml,Javascript,Xml,我有以下响应,我想使用javascript只读success元素: <?xml version="1.0" encoding="UTF-8"?> <OTA_HotelResNotifRS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http:
<?xml version="1.0" encoding="UTF-8"?>
<OTA_HotelResNotifRS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.openvel.org/OTA/2003/05" EchoToken="'.$reference.'" TimeStamp="'.date('Y-m-d H:i:s').'" Version="1.0">
<Success>'.$Meassage.'</Success>
</OTA_HotelResNotifRS>
“.$Meassage。”
类似本教程的内容?
使用DOMParser
,我在JSFIDLE中尝试了您的XML字符串,希望对您有所帮助。
xml响应是否为字符串?。感谢您的回答,但是“无法读取未定义的属性'childNodes'”在实现解决方案后出现此错误。给定的xml字符串中是否存在一些格式问题?如果您使用的是像我的JSFIDLE示例中那样的字符串文本,请确保正确地转义所有引号。