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 7968957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:09:35+00:00 2026-06-04T07:09:35+00:00

I have SVG string and I need to extract its two attributes: width and

  • 0

I have SVG string and I need to extract its two attributes: width and height.

I can’t use some XML parser since I am using this with Titanium Studio framework so I don’t have DOM anywhere.

SVG’s looks like this:

<svg xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" version="1.1" width="768" height="1005" space="preserve">
    LOT OF DATA HERE... <></> etc
</svg>

I started with something like this:

var width = svgString.match( /^<svg.\width.=.(.*)$>/gm );

It’s 4 AM and my brain is just not working.
If someone could help it would be great! Thx.

  • 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-04T07:09:36+00:00Added an answer on June 4, 2026 at 7:09 am

    Assuming jmar777’s code works, I would use a different, more conservative, regex, which allows for optional spaces, optional quotes and confirms that values are from svg tag itself (and not from some other tag if absent in svg tag). This might or might not make difference in your case, depending on where you get those svgs and how they are formed.

    var width = svgString.match(/^<svg[^>]*width\s*=\s*\"?(\d+)\"?[^>]*>/)[1];
    var height = svgString.match(/^<svg[^>]*height\s*=\s*\"?(\d+)\"?[^>]*>/)[1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF 2 application which creates some SVG content. How can i
I have RaphaelJS based canvas, where user can do some work. I need to
I have some SVG embedded into a web page and need to copy a
I have this svg: <circle cx=50 cy=100 r=50 stroke-width=0 fill=orange/> <polygon points=0,100, 50,50 100,100
I have a simple example ( SVG source ) looks like you can see
I have a php script (generator.php) which generates certain HTML/XML/SVG depending on various conditions.
I have SVG graphics (just text) between html <body> tags. I need the size
Scenario: I have SVG image that I can zoom-in and zoom-out. Depending on the
I use the code below to have SVG embedded in HTML5. The only problem
Say you have a SVG image such as this: Each card is its own

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.