SAXand characters

Discussion in 'XML' started by remi, May 14, 2005.

  1. remi

    remi Guest

    Hi,

    I don't know if I am in the good newsgroup... Anyway, feel free to
    redirect me where it is more relevant.

    I am using SAX (with python) to parse a XML file like this one :

    <section id="1" name="Nom" description="blabla">
    <sousSection id="1" thema="mon thème">
    some text here mixed with html code
    some lists in html
    </sousSection>
    <sousSection id="2" thema="thème 2">
    another paragraph
    </sousSection>

    I use characters() method but this one one is called everytime there is
    a newline in the text between the <sousSection...> </sousSection> wiwh
    seem to be a normal behavior.

    How can I have characters method called once and act on the whole
    paragraph in "one shot" ?
    Thanks for your help.
    Rémi.
     
    remi, May 14, 2005
    #1
    1. Advertising

  2. In article <O_jhe.58941$>,
    remi <> wrote:

    > I use characters() method but this one one is called everytime there is
    > a newline in the text between the <sousSection...> </sousSection> wiwh
    > seem to be a normal behavior.


    Yes.

    > How can I have characters method called once and act on the whole
    > paragraph in "one shot" ?


    You need to buffer the characters yourself and not act on them until you
    see the next non-characters event.

    --
    Henri Sivonen

    http://hsivonen.iki.fi/
     
    Henri Sivonen, May 14, 2005
    #2
    1. Advertising

  3. remi

    Terry Milan Guest

    If this paragraph were put in a CDATA section, would he be able to get them
    all at once as CDATA?

    "Henri Sivonen" <> wrote in message
    news:...
    > In article <O_jhe.58941$>,
    > remi <> wrote:
    >
    >> I use characters() method but this one one is called everytime there is
    >> a newline in the text between the <sousSection...> </sousSection> wiwh
    >> seem to be a normal behavior.

    >
    > Yes.
    >
    >> How can I have characters method called once and act on the whole
    >> paragraph in "one shot" ?

    >
    > You need to buffer the characters yourself and not act on them until you
    > see the next non-characters event.
    >
    > --
    > Henri Sivonen
    >
    > http://hsivonen.iki.fi/
     
    Terry Milan, May 14, 2005
    #3
  4. remi

    remi Guest

    Terry Milan a écrit :
    > If this paragraph were put in a CDATA section, would he be able to get them
    > all at once as CDATA?


    Yes, it is finally what i did. It seems to be fine for now.
    Could we say that using CDATA is mandatory if you have "mixed" content
    between two tags ?

    Here is a part of my XML file :
    #------
    <section description="description" id="1" name="main title">
    <sousSection id="1" thema="titre">
    <![CDATA[This text deals with 1 point :
    <ol>
    <li>point one</li>
    <ol>
    Here is a web site : <a href="website.fr">http://website.fr</a>]]>
    </sousSection>
    <sousSection id="2" thema="title2">
    #-------
    Thanks.
    Rémi Boulle.
     
    remi, May 14, 2005
    #4
  5. In article <yNphe.420$>,
    "Terry Milan" <> wrote:

    > If this paragraph were put in a CDATA section, would he be able to get them
    > all at once as CDATA?


    Not reliably. It might appear to work in some situations, but IIRC SAX
    doesn't guarantee that the whole chunk of text is reported in one
    callback.

    --
    Henri Sivonen

    http://hsivonen.iki.fi/
     
    Henri Sivonen, May 14, 2005
    #5
    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. Replies:
    2
    Views:
    770
  2. Stefan Mueller
    Replies:
    3
    Views:
    33,050
    Stefan Mueller
    Jul 23, 2006
  3. omegaman
    Replies:
    1
    Views:
    568
    omegaman
    Sep 21, 2004
  4. Micah
    Replies:
    2
    Views:
    346
    Micah
    Jun 2, 2006
  5. Replies:
    4
    Views:
    339
    Keith Thompson
    Dec 14, 2006
Loading...

Share This Page