5 ms·
What language? In Python, the `find`, `findall`, etc. methods take a namespace dictionary. E.g. result = doc.findall("//w:t", namespaces={"w": "..."}) In
by rhdunn 1y ago
What language?
In Python, the `find`, `findall`, etc. methods take a namespace dictionary. E.g.
result = doc.findall("//w:t", namespaces={"w": "..."})
In C# you can do:
var navigator = doc.Root!.CreateNavigator();
nsManager = new XmlNamespaceManager(navigator.NameTable);
nsManager.AddNamespace("w", "...");
var results = doc.Root?.XPathSelectElements("//w:t", nsManager);
In Java you need to enable a namespace-aware flag in the settings to get namespaces to work. I can't recall off-hand how to do that.
- etothepii 1y agoYes I'm talking Python. The namespaces are long, dare I say ugly, urls. Even though the xml file itself uses `<w:t` you can't unless you provide a dictionary as an argument that contains `{"w":"https://...."}` which means that you need to do a bunch of reading and understanding before you can start playing with the files.