Re: [xml] \n or \r missing when adding text-content

In fact, I'm building a xml tree from scratch, I'm not trying to read an existing one. The main problem is that I can't add text to a node without losing all sub-nodes \n and/or \r.

When I dump the tree, all xml nodes after the text part are dumped on only one line.

<?xml version="1.0"?>
    <Production Annee="1992" Type="964">Exemple de texte
<Version Modele="Carrera RS" Puissance="260"/><Version Modele="Turbo 3.6" Puissance="360"/></Production>
    <Production Annee="1995" Type="993">
      <Version Modele="Turbo" Puissance="408">
        <Evolution Modele="GT2" Puissance="450"/>

Because of the text "Exemple de texte", on line #4, all the sub-tree of this node is dumped as one line, until the end of this node.

 I would like to obtain rather something like that :

<?xml version="1.0"?>
    <Production Annee="1992" Type="964">
        Exemple de texte
        <Version Modele="Carrera RS" Puissance="260"/>
        <Version Modele="Turbo 3.6" Puissance="360"/>
    <Production Annee="1995" Type="993">
      <Version Modele="Turbo" Puissance="408">

If I use xmlNodeAddContent, xmlNodeSetContent or even xmlNewText, nevermind, still the same one line.

 I really don't understand what the hell is going on.


Daniel Veillard wrote:
On Tue, May 10, 2005 at 11:00:22AM +0200, Remy HAREL wrote:

All the \n or the \n seem to be missing. How can I add some content and keep the first form ? Almost each node in the project I'm currently working on need text content.

  that's definitely not libxml2 default behaviour. Someone made the
mistake to call xmlKeepBlanksDefault(0) changing the default behaviour
of all parser instances created by the library. The default behaviour
is to keep all blanks nodes as required by the XML-1.0 spec. Switching
the behaviour off can be done on a case by case basis with the new
xmlReadxxx APIs.


Remy HAREL          -        Teamlog        |
Linux registered user #224740               |
France Telecom Recherche & Developpement    |
__________________@ @|

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]