Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a couple (20) of svg-fonts (xml based font format), on average each one of them is about 300kb and contains about 100 Glyph-tags. I would like to process each glyph with Inkscape. So the part of XML-processing I would like to do with a Powershell script is:

  1. Open the font as XML
  2. Iterate over each glyph, grab the value of an attribute and save a temp svg (XML) parameterised with this value
  3. Process this file with Inkscape
  4. Read each of this files
  5. Built a new font-file with the new data
  6. Save the font, delete the glyph

I have read a lot of Powershell XML tutorials and tried a few times, and there is one thing I do not know what is wrong, but I'm getting each glyph from the font with this line:

$nodes = Select-Xml -Content $( Get-Content -Path $_.FullName )  -XPath "//glyph" -Namespace $namespaces

needs a lot of time and delivers 60 glyphs, even if their are more in the font. All the rest of the script is working properly, but if I image to process all 20 fonts (will be more in the future) it will take a whole day and not all glyphs are processed.

So, is there a failure in reading the file and parsing the XML? Why is this so incredibly slow and why are not all glyphs processed?

share|improve this question
Do your SVG's have DOCTYPE declarations in them? If so, have you tried removing them to see if that makes a difference? – Daniel Haley Dec 14 '11 at 17:20
Hello! removing the DOCTYPE does the trick with the speed, thanks a lot! But still not more than 60 glyphs are processed, even if their are more. Why could that be? – philipp Dec 15 '11 at 11:48
Sorry, I'm not sure about why it's only processing 60 glyphs. – Daniel Haley Dec 15 '11 at 17:49
could you put a link with some of your files to play with it and search a workaround? – mjsr Dec 30 '11 at 1:09
@voodoomsr i don't know what you mean with: »put a link with some of your files«, could you post a link or something that explains with a little more detail what this approach is about? – philipp Dec 31 '11 at 6:29

Couple options for you:

  1. Select-Xml -Path test.xml -XPath "//*[local-name()='glyph']")
  2. [xml] $x = gc test.xml ; $x.SelectNodes("//*[local-name()='glyph']")

Both select 95 nodes very quickly. I tested what you put in paste bin.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.