Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.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_Xml Namespaces - Fatal编程技术网

无法使用名称空间和javascript解析Xml

无法使用名称空间和javascript解析Xml,javascript,xml,xml-namespaces,Javascript,Xml,Xml Namespaces,我无法解析具有名称空间的XML: 以下是我的XML: <w:drawing> <wp:inline distT="0" distB="0" distL="0" distR="0"> <wp:extent cx="2371148" cy="1999323"/> <wp:effectExtent l="0" t="0" r="0" b="0"/> <wp:docPr id="1" name="Image 1"/&g

我无法解析具有名称空间的XML:

以下是我的XML:

<w:drawing>
    <wp:inline distT="0" distB="0" distL="0" distR="0">
    <wp:extent cx="2371148" cy="1999323"/>
    <wp:effectExtent l="0" t="0" r="0" b="0"/>
    <wp:docPr id="1" name="Image 1"/>
        <wp:cNvGraphicFramePr>
            <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
        </wp:cNvGraphicFramePr>
        <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
            <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                    <pic:nvPicPr>
                        <pic:cNvPr id="0" name="Image2.png"/>
                        <pic:cNvPicPr/>
                    </pic:nvPicPr>
                <pic:blipFill>
                    <a:blip r:embed="rId9">
                        <a:extLst>
                            <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                            <a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
                            </a:ext>
                            </a:extLst>
                    </a:blip>
                    <a:stretch>
                        <a:fillRect/>
                    </a:stretch>
                </pic:blipFill>
                    <pic:spPr>
                        <a:xfrm>
                            <a:off x="0" y="0"/>
                            <a:ext cx="2371148" cy="1999323"/>
                        </a:xfrm>
                    <a:prstGeom prst="rect">
                        <a:avLst/>
                    </a:prstGeom>
                    </pic:spPr>
                </pic:pic>
            </a:graphicData>
        </a:graphic>
    </wp:inline>
</w:drawing>
我想获取标记,但是这个标记似乎没有加载到xml中

我知道冒号的意思是这些是名称空间,这就是为什么我尝试使用getElementsByTagNameNS“*”,“blipFill”,但结果只是这个xmlTag,而不是他的孩子

下面是一个JSFIDLE,它显示标记为空


我必须在文档的开头添加正确的名称空间定义

<?xml version="1.0" ?>
<w:document mc:Ignorable="w14 wp14"
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"   

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
xmlns:o="urn:schemas-microsoft-com:office:office" 
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main ...

在中删除r:in,但您也会得到一个解析错误节点,抱怨在根元素中未定义w:prefix。是的,我在开头添加了名称空间定义,它现在可以工作了: