Coding issue with XML for word document

accessnewbie at gmail.com accessnewbie at gmail.com
Wed Feb 8 16:11:51 EST 2017


> myBlurb = "<w:cr/><w:r><w:rPr><w:b/></w:rPr><w:t>My Favorite Cars - </w:t></w:r><w:r><w:t> My favorite cars are available at </w:t></w:r>"  + myText + "<w:cr/>
> 
> What am I missing here?

Sorry about posting in python group. My XML coding was embedded in python script. I will do better next time.

The problem was with placement of tags. The following worked:


myBlurb = "<w:r><w:cr/><w:rPr><w:b/></w:rPr><w:t>My Favorite Cars - </w:t></w:r><w:r><w:t> My favorite cars are available at </w:t></w:r><w:r><w:t>"  + myText + "</w:t><w:cr/></w:r>

I needed to put the carriage return <w:cr> within the <w:r> wrapper. I also needed to add the text elements <w:t> and </w:t> before and after the variable.



More information about the Python-list mailing list