Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Loop over chars in a string

Loop over chars in a string

Scheduled Pinned Locked Moved XML / XSL
xmlquestioncode-review
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KenBonny
    wrote on last edited by
    #1

    I have a string in an XML file and I want to display each letter (or number) in a different box (div). So I made the div tag and I want to display one letter (or number) in it. Currently I have this code:

    ...

    name person

    ...
    1

    Any advice on what I can improve? Because this isn't working. Thanks in advance!

    G 1 Reply Last reply
    0
    • K KenBonny

      I have a string in an XML file and I want to display each letter (or number) in a different box (div). So I made the div tag and I want to display one letter (or number) in it. Currently I have this code:

      ...

      name person

      ...
      1

      Any advice on what I can improve? Because this isn't working. Thanks in advance!

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      1. Use $test as a constant. 2. Rename your param $text to something else, e.g. $sub_text and select="$text" (without this you have an empty string 3. Your if test is incorrect. count does not have a '$' in front of it. "not($count = string-length($text))" 4. The last parm $text should be renamed to $sub_text and select attrib set to "substring($text, $count + 1)" since you should be chopping off the first character and passing it to the next recursion.

      "We make a living by what we get, we make a life by what we give." --Winston Churchill

      modified on Tuesday, June 7, 2011 7:55 PM

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups