Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从xml模式中读取元素值?_Javascript_Xml - Fatal编程技术网

Javascript 如何从xml模式中读取元素值?

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:

我有以下响应,我想使用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://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示例中那样的字符串文本,请确保正确地转义所有引号。