1

I'm not able to parse an XML with namespaces:

Here's my 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>

I would like to get the tag, but This tag doesn't seem to be loaded in the xml.

I know the colons mean these are namespaces, that's why I tried to use getElementsByTagNameNS('*', 'blipFill'), but the result is only this xmlTag (not his children)

Here's a jsfiddle that shows that the tag is empty

http://jsfiddle.net/TaGmk/1/

2
  • 1
    Remove r: in <a:blip r:embed="rId9">: jsfiddle.net/TaGmk/2 But you'll also get a parse error node complaining w: prefix is not defined in your root element.
    – Passerby
    Commented Jun 13, 2013 at 11:01
  • Yep, I have added the namespace definition at the beginning and it works now: <?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 ...
    – edi9999
    Commented Jun 13, 2013 at 11:43

1 Answer 1

0

I had to add the correct namespace definition at the beginning of the document

<?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 ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.