Skip to content

NameError: global name 'ct_parse_xml' is not defined #1

@rokayattila

Description

@rokayattila

Hi!

I want to edit my custom.xml file. However, I am not able to run my script:

import string
from docx.shared import Inches

document = Document('demo.docx')
print "revision is: " % document.custom_properties["Revision"]
document.custom_properties["Name"] = "Rene"
document.custom_properties["Revision"] = "1.0.0"
document.save("demo.docx")

I get the following error message:

```c:\Users\arokay.RRINTRA\Desktop\test>python newway.py
Traceback (most recent call last):
  File "newway.py", line 8, in <module>
    print "revision is: " % document.custom_properties["Revision"]
  File "C:\Python27\lib\site-packages\python_docx-0.8.5-py2.7.egg\docx\document.
py", line 117, in custom_properties
    return self._part.custom_properties
  File "C:\Python27\lib\site-packages\python_docx-0.8.5-py2.7.egg\docx\parts\doc
ument.py", line 44, in custom_properties
    return self.package.custom_properties
  File "C:\Python27\lib\site-packages\python_docx-0.8.5-py2.7.egg\docx\opc\packa
ge.py", line 53, in custom_properties
    return self._custom_properties_part.custom_properties
  File "C:\Python27\lib\site-packages\python_docx-0.8.5-py2.7.egg\docx\opc\packa
ge.py", line 193, in _custom_properties_part
    custom_properties_part = CustomPropertiesPart.default(self)
  File "C:\Python27\lib\site-packages\python_docx-0.8.5-py2.7.egg\docx\opc\parts
\customprops.py", line 50, in default
    custom_properties_part = cls._new(package)
  File "C:\Python27\lib\site-packages\python_docx-0.8.5-py2.7.egg\docx\opc\parts
\customprops.py", line 71, in _new
    customProperties = CT_CustomProperties.new()
  File "C:\Python27\lib\site-packages\python_docx-0.8.5-py2.7.egg\docx\oxml\cust
omprops.py", line 35, in new
    customProperties = ct_parse_xml(xml)
NameError: global name 'ct_parse_xml' is not defined```

Could you please help me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions