FOAK: XML problem

Discussion in 'UK Motorcycles' started by Wicked Uncle Nigel, Jun 22, 2010.

  1. I have to hand-carve some XML. It's produced by a tool that encodes some
    of it in UTF-8, but ignores some international characters. No biggie,
    I'm replacing those with the appropriate UTF codes.

    I'm struggling slightly (and getting conflicting advice) on what do with
    ampersands, <, >, carriage-returns and line-feed contained within a
    (free-text) item in the file.

    I've tried a few combinations, but my validation tool keeps barfing on
    an "Invalid character" error. And this was needed yesterday.

    Hay-ulllp!
     
    Wicked Uncle Nigel, Jun 22, 2010
    #1
    1. Advertisements

  2. Wicked Uncle Nigel

    Simon Wilson Guest

    This no good then? http://en.wikipedia.org/wiki/XML#Escaping

    I thought that &lt &gt etc. worked?
     
    Simon Wilson, Jun 22, 2010
    #2
    1. Advertisements

  3. Wicked Uncle Nigel

    Jim Guest

    There are escaping conventions for this kind of stuff:

    < = &lt;
    & = &amp;

    line break can be represented as #xD #xA if you need to.

    There should be a function available in your language libraries to do
    this, to be honest.
     
    Jim, Jun 22, 2010
    #3
  4. Using the patented Mavis Beacon "Hunt&Peck" Technique, Simon Wilson
    So did I. And they do.

    The stupid fucking validation tool I was using allows you to edit the
    file, but still runs validation against the un-changed version.

    Genius.

    Thanks.
     
    Wicked Uncle Nigel, Jun 22, 2010
    #4
  5. Wicked Uncle Nigel

    Pete Fisher Guest

    If you really are hand carving a one off, this free tool might have
    speeded up the process if there was a large chunk of text with many
    characters to be escaped.

    http://www.myxmltools.com/xml-escape-tool.shtml
    --
    +-------------------------------------------------------------------+
    | Pete Fisher at Home: |
    | Voxan Roadster Yamaha WR250Z/Supermoto "Old Gimmer's Hillclimber" |
    | Gilera GFR * 2 Moto Morini 2C/375 Morini 350 "Forgotten Error" |
    +-------------------------------------------------------------------+
     
    Pete Fisher, Jun 22, 2010
    #5

  6. There should, but they don't fucking work. Don't ask. Just... don't.
     
    Wicked Uncle Nigel, Jun 22, 2010
    #6
  7. Wicked Uncle Nigel

    Simon Guest

    <!--[CDATA[ text ]]--> is what you are looking for, methinks.
     
    Simon, Jun 22, 2010
    #7
  8. Wicked Uncle Nigel

    Ben Guest

    Aye, that's the proper way of doing it in XML.

    http://www.w3schools.com/xml/xml_cdata.asp

    For a noddy explanation.
     
    Ben, Jun 22, 2010
    #8
  9. Using the patented Mavis Beacon "Hunt&Peck" Technique, Ben
    Ahah! Noddy is good. Thanks.
     
    Wicked Uncle Nigel, Jun 22, 2010
    #9
  10. Wicked Uncle Nigel

    Simon Guest

    Not really. They are HTML entity characters, nothing to do with XML -
    what is happening is the XML parser (in your browser, or however you
    are opening the file) is reading them as part of the markup.
     
    Simon, Jun 22, 2010
    #10
  11. Using the patented Mavis Beacon "Hunt&Peck" Technique, Champ
    Noted, ta.
     
    Wicked Uncle Nigel, Jun 23, 2010
    #11
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.