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. CDATA in element attributes?

CDATA in element attributes?

Scheduled Pinned Locked Moved XML / XSL
2 Posts 2 Posters 1 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.
  • Z Offline
    Z Offline
    Zyxil
    wrote on last edited by
    #1

    does anyone know how to tell the parser to ignore special characters in element attributes? say i have an element: <setting name="CommandLine" value="notepad.exe "C:\Documents and Settings\moralja\My Documents\text\text.txt""></setting> this will not parse correctly because of the quote marks inside the value attribute. just encoding the quotes with " works, but i am going to have possibly thousands of entries, i would rather have some way, like the CDATA thing, to tell the parser to ignore the data altogether any ideas? -John

    P 1 Reply Last reply
    0
    • Z Zyxil

      does anyone know how to tell the parser to ignore special characters in element attributes? say i have an element: <setting name="CommandLine" value="notepad.exe "C:\Documents and Settings\moralja\My Documents\text\text.txt""></setting> this will not parse correctly because of the quote marks inside the value attribute. just encoding the quotes with " works, but i am going to have possibly thousands of entries, i would rather have some way, like the CDATA thing, to tell the parser to ignore the data altogether any ideas? -John

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      John Morales wrote: just encoding the quotes with " works, but i am going to have possibly thousands of entries, i would rather have some way, like the CDATA thing, to tell the parser to ignore the data altogether I may be wrong but the answer is no. If you think about it having quotes like that in the attribute value breaks the whole parsing of the element. I would recommend you move that attribute to an element e.g.:

      <setting name="CommandLine">notepad.exe "C:\Documents and Settings\moralja\My Documents\text\text.txt"</setting>

      It actually makes more sense that way too. And if you think that will be a pain with thousands of entries, you could always write a simple XSL file which does it for you in a couple of minutes :) regards, Paul Watson Bluegrass Cape Town, South Africa Simon Walton wrote: "You come across a lot of people who call themselves realists, when they are actually pessimists attempting to look intelligent."

      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