Forum

Xpath/xml nodes not playing well with svg document

he belovvvved berlin crowd,

just found a little bugger, see screenshot and patch attached.
maybe it’s two different issues, maybe comes down to just one:

  1. why does xpath even care and doesn’t work here?
  2. attribute being cloned to child elements upon split

-readme

xml_bug.zip (12.8 kB)

hey!

while not being an expert in xml…
the attached patch works with the original xml doc!

so i am unsure about this being a bug. might be that this is the way xpath should work?! it feels complicated though. any xml expert should feel invited teaching us xml namespaces here.

xPathWithNameSpace.v4p (76.4 kB)

this (down at the edit) is kind of a good understandable answer.
in short, xpath is not supposed to automagically deal namespaces.
in your case, a namespace is defined, but no prefix. so you have to use the namespacemanager to add a prefix yourself to be able to do the query.

and this is the working-around-namespaces hack for the lazy

//*[local-name()='g'](local-name()='g')