python-openxml / python-docx

Create and modify Word documents with Python
MIT License
4.38k stars 1.08k forks source link

support more keys in nsmap. #1382

Closed flyingpang closed 2 months ago

flyingpang commented 2 months ago
image

When I used package to parse textbox in docx file, I found a namespace problem, so I had to redefine all elements that used xpath function (because xpath function couldn't support the incoming nsmap parameter). Could you support more key values for nsmaps or support xpath nsmap parameters.

scanny commented 2 months ago

@flyingpang docx.oxml.ns.nsmap is a dict. So just add the values you need before you call the parser or xpath.

Like:

from docx.oxml.ns import nsmap

nsmap["wpg"] = "http://schemas...."

If there are specific ones you find yourself needing let us know and we can add them.