can I use element tree for handling special characters in xml text?

Discussion in 'Python' started by hackingKK, Jul 27, 2011.

  1. hackingKK

    hackingKK Guest

    Hello all.
    I have been waiting a lot to ask this question and I did ask some days
    back but probably could not put it the proper way.
    I want to know how I can safely include special characters like & or >
    in xml text?
    For example I store a small xml file containing list of organisations.
    Many names have an "&" in the name as in brian & turner.
    so the xml noad will be <orgname> brian & turner </orgname>
    But I know this won't work directly.
    my code naturally fails when I try to insert such data.
    Can any one suggest the right way of parsing this kind of strings and
    treat & like characters as part of the literal string?
    Hope my question is clear this time.
    Happy hacking.
    Krishnakant.
     
    hackingKK, Jul 27, 2011
    #1
    1. Advertising

  2. hackingKK wrote:

    > I have been waiting a lot to ask this question and I did ask some days
    > back but probably could not put it the proper way.


    You still can't. <http://www.catb.org/~esr/faqs/smart-questions.html>

    But to spare everyone yet another try:

    > I want to know how I can safely include special characters like & or >
    > in xml text?


    (I don't know what you want to know, so don't ask me that.)

    You need CDATA sections for this. That is not a Python problem.

    You should get a real name.

    --
    PointedEars

    Bitte keine Kopien per E-Mail. / Please do not Cc: me.
     
    Thomas 'PointedEars' Lahn, Jul 28, 2011
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Mueller
    Replies:
    3
    Views:
    33,037
    Stefan Mueller
    Jul 23, 2006
  2. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,128
  3. Replies:
    1
    Views:
    1,576
    Greg R. Broderick
    Apr 5, 2007
  4. Replies:
    2
    Views:
    1,095
    Ingo Menger
    May 31, 2007
  5. HANM
    Replies:
    2
    Views:
    723
    Joseph Kesselman
    Jan 29, 2008
Loading...

Share This Page