Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:08:43+00:00 2026-06-03T13:08:43+00:00

I generate a .svg image (which is a xml file) using Inkscape. I set

  • 0

I generate a .svg image (which is a xml file) using Inkscape. I set a node’s ID to ‘mount-arm-r’. I want to read the attributes ‘x’, ‘y’, from that element. I can’t seem to select the rect elements.

python: I tried XPath, or manually one depth at a time. I think I want:

def parse_xml():
    tree = ElementTree()
    tree.parse("torso-human.svg")                        
    for node in tree.findall('.//rect'): print 'n=', node

xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="125.39109"
   height="217.70497"
   id="svg3136"
   version="1.1"
   inkscape:version="0.48.1 "
   sodipodi:docname="torso-human.svg">
  <defs
     id="defs3138" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.7"
     inkscape:cx="134.17406"
     inkscape:cy="65.046531"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     fit-margin-top="0"
     fit-margin-left="0"
     fit-margin-right="0"
     fit-margin-bottom="0"
     inkscape:window-width="678"
     inkscape:window-height="714"
     inkscape:window-x="149"
     inkscape:window-y="198"
     inkscape:window-maximized="0" />
  <metadata
     id="metadata3141">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(-94.4375,-394.94334)">
    <path
       style="fill:#f7b42a;fill-opacity:1;stroke:#000000;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
       d="m 123.77824,405.89569 c 10.24991,-3.38432 20.79684,-5.42837 31.38251,-7.00357 10.08459,-3.35769 18.78867,2.77879 26.91852,7.6971 11.31402,4.36385 16.77569,16.06584 23.028,25.60256 4.24045,8.35939 4.95844,18.18912 6.47883,27.32923 0.81646,12.84443 3.26716,25.52723 3.78171,38.41123 0.89978,12.5961 -0.39774,25.23801 1.24629,37.81448 1.02427,12.22291 -1.40473,24.93719 -8.43715,35.07825 -7.47966,16.13252 -19.54923,31.09303 -36.14012,38.36243 -9.64999,2.44233 -17.82857,-5.59005 -27.35583,-5.23341 -14.78262,-5.55 -28.81674,-15.655 -35.88284,-30.0959 -5.41188,-15.13741 -10.887811,-30.71753 -11.350781,-46.928 3.049751,-10.81513 3.565751,-21.8035 1.94578,-33.0368 1.513801,-9.31727 -2.45929,-18.6844 -0.0771,-27.86458 4.302571,-16.70927 8.728671,-33.70461 17.388141,-48.73973 2.49669,-3.69472 5.83731,-6.99007 7.074,-11.39329 z"
       id="path3757"
       inkscape:connector-curvature="0" />
    <rect
       style="fill:#ff0000;fill-opacity:1;stroke:#aa0000;stroke-width:2.06586957;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
       id="mount-arm-r"
       width="24.593687"
       height="4.9187374"
       x="279.40387"
       y="403.92834"
       transform="matrix(0.96592583,0.25881905,-0.25881905,0.96592583,0,0)"
       ry="1.8705337" />
    <rect
       ry="2.0732613"
       transform="matrix(0.14071606,0.99004999,-0.99004999,0.14071606,0,0)"
       y="-109.61398"
       x="607.01672"
       height="5.4518275"
       width="27.259138"
       id="mount-leg-l"
       style="fill:#ff0000;fill-opacity:1;stroke:#aa0000;stroke-width:2.2897675;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
       inkscape:transform-center-x="-10.607363"
       inkscape:transform-center-y="-7.3172785" />
    <rect
       inkscape:transform-center-y="-4.1491271"
       inkscape:transform-center-x="-9.047332"
       style="fill:#ff0000;fill-opacity:1;stroke:#aa0000;stroke-width:1.76860404;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
       id="mount-leg-r"
       width="21.05481"
       height="4.2109618"
       x="585.27789"
       y="-149.50224"
       transform="matrix(-0.03269097,0.99946551,-0.99946551,-0.03269097,0,0)"
       ry="1.6013756" />
  </g>
</svg>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:08:44+00:00Added an answer on June 3, 2026 at 1:08 pm

    You’re forgetting the SVG namespace, which is declared on the root element (xmlns="http://www.w3.org/2000/svg"). Hence, you want something like this:

    SVG_NS = "http://www.w3.org/2000/svg"
    
    def parse_xml():
        tree = ElementTree()
        tree.parse("torso-human.svg")                        
        for node in tree.findall('.//{%s}rect' % SVG_NS):
            print 'n=', node
    

    See http://effbot.org/zone/element-namespaces.htm for some more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to generate an HTML file using a PHP script which
I have a font in ttf file and want to generate SVG with text
I am using SVG-Edit to create a pretty big SVG image file. The problem
I have a php script (generator.php) which generates certain HTML/XML/SVG depending on various conditions.
I generate some code using CXF from a WSDL-file. When compiling the code with
I am using nokogiri to generate svg pictures. I would like to add the
Is there any application to generate an XSL Stylesheet from an XML file? I
I have an place where i upload an SVG file using paperclip, and get
I'm using HighStock to generate some charts in browser. But now I want to
I'd like to use Matplotlib and pyplot to generate an svg image to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.