Code

adding getElementById() to inkex
authoraurium <aurium@users.sourceforge.net>
Wed, 26 Aug 2009 15:32:53 +0000 (15:32 +0000)
committeraurium <aurium@users.sourceforge.net>
Wed, 26 Aug 2009 15:32:53 +0000 (15:32 +0000)
share/extensions/inkex.py

index 2ae5d6c21377caab8bd25217fb5dd29e3137956d..665575c6b67b0047a98d2f7af66ba42409b7821f 100755 (executable)
@@ -166,6 +166,14 @@ class Effect:
             for node in self.document.xpath(path, namespaces=NSS):
                 self.selected[i] = node
 
+    def getElementById(self, id):
+        path = '//*[@id="%s"]' % id
+        el_list = self.document.xpath(path, namespaces=NSS)
+        if el_list:
+          return el_list[0]
+        else:
+          return None
+
     def getdocids(self):
         docIdNodes = self.document.xpath('//@id', namespaces=NSS)
         for m in docIdNodes: