samedi 9 mai 2015

PHP Append XML document with namespaces

I'm trying to parse docx files in PHP. Now I want to append document.xml file (that is main part of unzipped docx file). The structure is:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <w:document xmlns:wpc="http://ift.tt/JiuBoL"
xmlns:mc="http://ift.tt/pzd6Lm"                               xmlns:w="http://ift.tt/JiuBoE"             
mc:Ignorable="w14 wp14">
        <w:body>
            <w:p w:rsidR="00080C51" w:rsidRDefault="00080C51">
                <w:pPr>
                    <w:pStyle w:val="a3"/>
                    <w:ind w:left="1020"/>
                    <w:rPr>
                        <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
                        <w:sz w:val="22"/>
                        <w:szCs w:val="22"/>
                    </w:rPr>
                </w:pPr>
                <w:bookmarkStart w:id="0" w:name="_GoBack"/>
                <w:bookmarkEnd w:id="0"/>
            </w:p>
            <w:sectPr w:rsidR="00080C51">
                <w:pgSz w:w="11906" w:h="16838"/>
                <w:pgMar w:top="850" w:right="850" w:bottom="850" w:left="1417" w:header="708" w:footer="708" w:gutter="0"/>
                <w:cols w:space="708"/>
                <w:docGrid w:linePitch="360"/>
            </w:sectPr>
        </w:body>
    </w:document>

What I want to do is add new child <w:p>some text</w:p> tag to <w:body> tag. How can I do this?

There're a lot of ways to work with XML documents in PHP, like DOM, SimpleXMLElement. But which one can help me achieve this?

Aucun commentaire:

Enregistrer un commentaire