replacing node with php in word doc as xml?
Posted: Fri Aug 29, 2008 10:13 pm
Here's a good one...
I need to use Word docs as templates, basically a two column table, the left column is always the same (like an array key, but it has text) and the right column may be the same as the template, or may reflect user input from a form.
So I need to search the xml for the node and replace it selectively
Yes, I have set bookmarks in Word that will programmatically match data from the form. This is for Section 508 accessibility, so there are provision numbers eg "a119421":
(This is the bookmark of the first - and only, in this doc - right-side node that I want to be able to manipulate) (HINT - it is almost at the end of the file, the rest is all the word header nonsense)
I have read a little about simpleXML in PHP, but I'm not sure how to work with the xml code generated for the word doc.
And I need to keep the Word formatting because I have to write a new word doc to the filesystem and attach it to an email - all the pieces are there except this node replacement business
So either the right column will stay as is, or it will change to "N/A"
I already worked this system for a simple csv Excel file, now client wants Word doc attachment...
My "mini.xml" file with only one row/two columns (also attached as mini.zip, .xml not allowed):
I need to use Word docs as templates, basically a two column table, the left column is always the same (like an array key, but it has text) and the right column may be the same as the template, or may reflect user input from a form.
So I need to search the xml for the node and replace it selectively
Yes, I have set bookmarks in Word that will programmatically match data from the form. This is for Section 508 accessibility, so there are provision numbers eg "a119421":
Code: Select all
<aml:annotation aml:id="2" w:type="Word.Bookmark.Start" w:name="a119421"/>I have read a little about simpleXML in PHP, but I'm not sure how to work with the xml code generated for the word doc.
And I need to keep the Word formatting because I have to write a new word doc to the filesystem and attach it to an email - all the pieces are there except this node replacement business
So either the right column will stay as is, or it will change to "N/A"
I already worked this system for a simple csv Excel file, now client wants Word doc attachment...
My "mini.xml" file with only one row/two columns (also attached as mini.zip, .xml not allowed):
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2" w:macrosPresent="no" w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve"><w:ignoreElements w:val="http://schemas.microsoft.com/office/word/2003/wordml/sp2"/><o:DocumentProperties><o:Title>Section 508 Template</o:Title><o:Author>Jim Tobias</o:Author><o:LastAuthor>user</o:LastAuthor><o:Revision>3</o:Revision><o:TotalTime>1</o:TotalTime><o:Created>2008-08-30T02:23:00Z</o:Created><o:LastSaved>2008-08-30T02:23:00Z</o:LastSaved><o:Pages>1</o:Pages><o:Words>50</o:Words><o:Characters>290</o:Characters><o:Company>Inclusive Technologies</o:Company><o:Lines>2</o:Lines><o:Paragraphs>1</o:Paragraphs><o:CharactersWithSpaces>339</o:CharactersWithSpaces><o:Version>11.0000</o:Version></o:DocumentProperties><w:fonts><w:defaultFonts w:ascii="Times New Roman" w:fareast="Times New Roman" w:h-ansi="Times New Roman" w:cs="Times New Roman"/></w:fonts><w:lists><w:listDef w:listDefId="0"><w:lsid w:val="31856AA1"/><w:plt w:val="HybridMultilevel"/><w:tmpl w:val="79C619BE"/><w:lvl w:ilvl="0" w:tplc="04090011"><w:start w:val="1"/><w:lvlText w:val="%1)"/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="list" w:pos="720"/></w:tabs><w:ind w:left="720" w:hanging="360"/></w:pPr></w:lvl><w:lvl w:ilvl="1" w:tplc="04090001"><w:start w:val="1"/><w:nfc w:val="23"/><w:lvlText w:val="?"/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="list" w:pos="1440"/></w:tabs><w:ind w:left="1440" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Symbol" w:h-ansi="Symbol" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="2" w:tplc="275A0C88"><w:start w:val="3"/><w:lvlText w:val="%3)"/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="list" w:pos="2340"/></w:tabs><w:ind w:left="2340" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="3" w:tplc="0409000F" w:tentative="on"><w:start w:val="1"/><w:lvlText w:val="%4."/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="list" w:pos="2880"/></w:tabs><w:ind w:left="2880" w:hanging="360"/></w:pPr></w:lvl><w:lvl w:ilvl="4" w:tplc="04090019" w:tentative="on"><w:start w:val="1"/><w:nfc w:val="4"/><w:lvlText w:val="%5."/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="list" w:pos="3600"/></w:tabs><w:ind w:left="3600" w:hanging="360"/></w:pPr></w:lvl><w:lvl w:ilvl="5" w:tplc="0409001B" w:tentative="on"><w:start w:val="1"/><w:nfc w:val="2"/><w:lvlText w:val="%6."/><w:lvlJc w:val="right"/><w:pPr><w:tabs><w:tab w:val="list" w:pos="4320"/></w:tabs><w:ind w:left="4320" w:hanging="180"/></w:pPr></w:lvl><w:lvl w:ilvl="6" w:tplc="0409000F" w:tentative="on"><w:start w:val="1"/><w:lvlText w:val="%7."/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="list" w:pos="5040"/></w:tabs><w:ind w:left="5040" w:hanging="360"/></w:pPr></w:lvl><w:lvl w:ilvl="7" w:tplc="04090019" w:tentative="on"><w:start w:val="1"/><w:nfc w:val="4"/><w:lvlText w:val="%8."/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="list" w:pos="5760"/></w:tabs><w:ind w:left="5760" w:hanging="360"/></w:pPr></w:lvl><w:lvl w:ilvl="8" w:tplc="0409001B" w:tentative="on"><w:start w:val="1"/><w:nfc w:val="2"/><w:lvlText w:val="%9."/><w:lvlJc w:val="right"/><w:pPr><w:tabs><w:tab w:val="list" w:pos="6480"/></w:tabs><w:ind w:left="6480" w:hanging="180"/></w:pPr></w:lvl></w:listDef><w:list w:ilfo="1"><w:ilst w:val="0"/></w:list></w:lists><w:styles><w:versionOfBuiltInStylenames w:val="4"/><w:latentStyles w:defLockedState="off" w:latentStyleCount="156"/><w:style w:type="paragraph" w:default="on" w:styleId="Normal"><w:name w:val="Normal"/><w:rsid w:val="005967AB"/><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="24"/><w:sz-cs w:val="24"/><w:lang w:val="EN-US" w:fareast="EN-US" w:bidi="AR-SA"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Heading1"><w:name w:val="heading 1"/><wx:uiName wx:val="Heading 1"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:rsid w:val="005967AB"/><w:pPr><w:pStyle w:val="Heading1"/><w:keepNext/><w:spacing w:before="240" w:after="60"/><w:outlineLvl w:val="0"/></w:pPr><w:rPr><w:rFonts w:cs="Arial"/><wx:font wx:val="Arial"/><w:b/><w:b-cs/><w:kern w:val="32"/><w:sz w:val="40"/><w:sz-cs w:val="32"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Heading2"><w:name w:val="heading 2"/><wx:uiName wx:val="Heading 2"/><w:basedOn w:val="Normal"/><w:rsid w:val="005967AB"/><w:pPr><w:pStyle w:val="Heading2"/><w:spacing w:before="100" w:before-autospacing="on" w:after="100" w:after-autospacing="on"/><w:outlineLvl w:val="1"/></w:pPr><w:rPr><wx:font wx:val="Arial"/><w:b/><w:b-cs/><w:sz w:val="32"/><w:sz-cs w:val="36"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Heading3"><w:name w:val="heading 3"/><wx:uiName wx:val="Heading 3"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:rsid w:val="00662193"/><w:pPr><w:pStyle w:val="Heading3"/><w:keepNext/><w:spacing w:before="240" w:after="60"/><w:outlineLvl w:val="2"/></w:pPr><w:rPr><w:rFonts w:cs="Arial"/><wx:font wx:val="Arial"/><w:b/><w:b-cs/><w:sz-cs w:val="26"/></w:rPr></w:style><w:style w:type="character" w:default="on" w:styleId="DefaultParagraphFont"><w:name w:val="Default Paragraph Font"/><w:semiHidden/></w:style><w:style w:type="table" w:default="on" w:styleId="TableNormal"><w:name w:val="Normal Table"/><wx:uiName wx:val="Table Normal"/><w:semiHidden/><w:rPr><wx:font wx:val="Times New Roman"/></w:rPr><w:tblPr><w:tblInd w:w="0" w:type="dxa"/><w:tblCellMar><w:top w:w="0" w:type="dxa"/><w:left w:w="108" w:type="dxa"/><w:bottom w:w="0" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style><w:style w:type="list" w:default="on" w:styleId="NoList"><w:name w:val="No List"/><w:semiHidden/></w:style><w:style w:type="character" w:styleId="Hyperlink"><w:name w:val="Hyperlink"/><w:basedOn w:val="DefaultParagraphFont"/><w:rsid w:val="00662193"/><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial"/><w:b/><w:color w:val="0000FF"/><w:u w:val="single"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="TOC1"><w:name w:val="toc 1"/><wx:uiName wx:val="TOC 1"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:autoRedefine/><w:semiHidden/><w:rsid w:val="00D15BC5"/><w:pPr><w:pStyle w:val="TOC1"/><w:tabs><w:tab w:val="right" w:leader="dot" w:pos="10790"/></w:tabs></w:pPr><w:rPr><wx:font wx:val="Arial"/><w:noProof/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="TOC2"><w:name w:val="toc 2"/><wx:uiName wx:val="TOC 2"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:autoRedefine/><w:semiHidden/><w:rsid w:val="00D15BC5"/><w:pPr><w:pStyle w:val="TOC2"/><w:ind w:left="240"/></w:pPr><w:rPr><wx:font wx:val="Arial"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="TOC3"><w:name w:val="toc 3"/><wx:uiName wx:val="TOC 3"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:autoRedefine/><w:semiHidden/><w:rsid w:val="00D15BC5"/><w:pPr><w:pStyle w:val="TOC3"/><w:ind w:left="480"/></w:pPr><w:rPr><wx:font wx:val="Arial"/></w:rPr></w:style></w:styles><w:divs><w:div w:id="1810979788"><w:bodyDiv w:val="on"/><w:marLeft w:val="0"/><w:marRight w:val="0"/><w:marTop w:val="0"/><w:marBottom w:val="0"/><w:divBdr><w:top w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto"/><w:left w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto"/><w:bottom w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto"/><w:right w:val="none" w:sz="0" wx:bdrwidth="0" w:space="0" w:color="auto"/></w:divBdr></w:div></w:divs><w:shapeDefaults><o:shapedefaults v:ext="edit" spidmax="3074"/><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1"/></o:shapelayout></w:shapeDefaults><w:docPr><w:view w:val="print"/><w:zoom w:percent="100"/><w:proofState w:spelling="clean" w:grammar="clean"/><w:attachedTemplate w:val=""/><w:defaultTabStop w:val="720"/><w:doNotHyphenateCaps/><w:punctuationKerning/><w:characterSpacingControl w:val="DontCompress"/><w:optimizeForBrowser/><w:relyOnVML/><w:allowPNG/><w:validateAgainstSchema/><w:saveInvalidXML w:val="off"/><w:ignoreMixedContent w:val="off"/><w:alwaysShowPlaceholderText w:val="off"/><w:compat><w:dontAllowFieldEndSelect/><w:useWord2002TableStyleRules/></w:compat><wsp:rsids><wsp:rsidRoot wsp:val="001419DE"/><wsp:rsid wsp:val="000810DA"/><wsp:rsid wsp:val="00081863"/><wsp:rsid wsp:val="00092559"/><wsp:rsid wsp:val="000F4064"/><wsp:rsid wsp:val="000F5BE2"/><wsp:rsid wsp:val="001419DE"/><wsp:rsid wsp:val="001C27C1"/><wsp:rsid wsp:val="0025419B"/><wsp:rsid wsp:val="00261AE9"/><wsp:rsid wsp:val="0030483F"/><wsp:rsid wsp:val="0036689C"/><wsp:rsid wsp:val="003D7900"/><wsp:rsid wsp:val="00447A17"/><wsp:rsid wsp:val="004A13CE"/><wsp:rsid wsp:val="004A3047"/><wsp:rsid wsp:val="005967AB"/><wsp:rsid wsp:val="005C75E5"/><wsp:rsid wsp:val="0064008E"/><wsp:rsid wsp:val="00662193"/><wsp:rsid wsp:val="00753FDE"/><wsp:rsid wsp:val="007954AE"/><wsp:rsid wsp:val="007D2D3B"/><wsp:rsid wsp:val="007D72FA"/><wsp:rsid wsp:val="00850D7F"/><wsp:rsid wsp:val="008B2E1C"/><wsp:rsid wsp:val="009065EE"/><wsp:rsid wsp:val="00914A88"/><wsp:rsid wsp:val="009201A2"/><wsp:rsid wsp:val="00991DED"/><wsp:rsid wsp:val="00A04379"/><wsp:rsid wsp:val="00A42A17"/><wsp:rsid wsp:val="00A462A7"/><wsp:rsid wsp:val="00AC3250"/><wsp:rsid wsp:val="00AD08ED"/><wsp:rsid wsp:val="00AF35A9"/><wsp:rsid wsp:val="00AF5B57"/><wsp:rsid wsp:val="00B33E97"/><wsp:rsid wsp:val="00B43C94"/><wsp:rsid wsp:val="00C84B83"/><wsp:rsid wsp:val="00CA300B"/><wsp:rsid wsp:val="00D15BC5"/><wsp:rsid wsp:val="00D1681A"/><wsp:rsid wsp:val="00D3526A"/><wsp:rsid wsp:val="00E37342"/><wsp:rsid wsp:val="00E8546C"/><wsp:rsid wsp:val="00EA0F40"/><wsp:rsid wsp:val="00F60713"/><wsp:rsid wsp:val="00F749CC"/></wsp:rsids></w:docPr><w:body><wx:sect><w:p wsp:rsidR="000810DA" wsp:rsidRDefault="000810DA" wsp:rsidP="000810DA"><aml:annotation aml:id="0" w:type="Word.Bookmark.Start" w:name="_Toc132015003"/></w:p><w:tbl><w:tblPr><w:tblW w:w="0" w:type="auto"/><w:tblLayout w:type="Fixed"/><w:tblLook w:val="01E0"/></w:tblPr><w:tblGrid><w:gridCol w:w="8208"/><w:gridCol w:w="4680"/></w:tblGrid><w:tr wsp:rsidR="000810DA" wsp:rsidRPr="0030483F" wsp:rsidTr="00991DED"><w:trPr><w:cantSplit/></w:trPr><w:tc><w:tcPr><w:tcW w:w="8208" w:type="dxa"/></w:tcPr><aml:annotation aml:id="1" w:type="Word.Bookmark.Start" w:name="ta119421"/><w:p wsp:rsidR="000810DA" wsp:rsidRPr="0030483F" wsp:rsidRDefault="00AC3250" wsp:rsidP="000810DA"><w:pPr><w:tabs><w:tab w:val="left" w:pos="4944"/><w:tab w:val="left" w:pos="7519"/></w:tabs></w:pPr><w:r wsp:rsidRPr="0030483F"><w:t> </w:t></w:r><w:r wsp:rsidR="000810DA" wsp:rsidRPr="0030483F"><w:t>(a) When software is designed to run on a system that has a keyboard, product functions shall be executable from a keyboard where the function itself or the result of performing a function can be discerned textually.</w:t></w:r><w:r wsp:rsidR="000810DA" wsp:rsidRPr="0030483F"><w:tab/></w:r><aml:annotation aml:id="1" w:type="Word.Bookmark.End"/><w:r wsp:rsidR="000810DA" wsp:rsidRPr="0030483F"><w:t> </w:t></w:r><w:r wsp:rsidR="000810DA" wsp:rsidRPr="0030483F"><w:tab/><w:t> </w:t></w:r></w:p></w:tc><aml:annotation aml:id="2" w:type="Word.Bookmark.Start" w:name="a119421"/><w:tc><w:tcPr><w:tcW w:w="4680" w:type="dxa"/></w:tcPr><w:p wsp:rsidR="000810DA" wsp:rsidRPr="0030483F" wsp:rsidRDefault="00991DED" wsp:rsidP="000810DA"><w:pPr><w:tabs><w:tab w:val="left" w:pos="4944"/><w:tab w:val="left" w:pos="7519"/></w:tabs></w:pPr><w:r><w:t>VPAT text supplemented with testing results, including all core functionality, with exceptions specifically noted.</w:t></w:r><aml:annotation aml:id="2" w:type="Word.Bookmark.End"/></w:p></w:tc></w:tr><aml:annotation aml:id="0" w:type="Word.Bookmark.End"/></w:tbl><w:p wsp:rsidR="001419DE" wsp:rsidRDefault="001419DE" wsp:rsidP="004A3047"/><w:sectPr wsp:rsidR="001419DE" wsp:rsidSect="004A3047"><w:pgSz w:w="15840" w:h="12240" w:orient="landscape" w:code="1"/><w:pgMar w:top="864" w:right="864" w:bottom="864" w:left="864" w:header="720" w:footer="720" w:gutter="0"/><w:cols w:space="720"/><w:docGrid w:line-pitch="360"/></w:sectPr></wx:sect></w:body></w:wordDocument>