Remix.run Logo
rhdunn 3 days 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 2 days ago | parent [-]

Yes 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.