On 2011-06-18 10:31, joakim@...1974... wrote:
I would like to be able to select nodes using XPath: https://bugs.launchpad.net/inkscape/+bug/798640
I naively assumed this would be trivial but when I dig in the code it doesn't seem like it is. In particular it is not immediately obvious how to convert between Inkscapes DOM model and libxml2:she model.
The simplest way I can think about now is a workaround involving loading the file with libxml2, and find the nodes in that tree instead.
I can't be the only one wanting to do things like this. I'm obviously missing something, right?
Actually I don't think you are missing something. As far as I know Inkscape has no xpath-like functionality (frankly it's not needed that often). It would be extremely cool to have though, also in the find dialog! You shouldn't need to load the SVG separately though, Inkscape's internal representation more or less mirrors the XML. Besides, I don't think you'd really want to operate on the XML representation, as then you get weird things like having to check for a fill in two places (either as part of the style or as a stand-alone attribute).
BTW, I'm assuming that you would be writing your own XPath processing code (perhaps not necessarily the parser, but at least the part that finds the required nodes). If you meant to reuse an existing library you can probably forget about it (unless it's set up in an extremely flexible manner).