[xml] Using some SAX functionality inside DOM: A quite newbie question



Hi All:
        I've been searching and googling at archive with no success.
        Well, I'm studying libxml2 to do some OSS projects.
To become familiar, I'm coding a xml to manpage converter called
xmlman (what a original name! :-) )
        Now I have some problems. For example, this is embbrain.xml:
<xmlman>

.... lot of things.....

 <sect><title>description</title>
 <p>
embbrain is a text editor. It is extremely simple to use, yet powerful enough to compete with other editors like <empha>vi</empha>(1) and <empha>emacs</empha>(1). It uses a embedded tecnology to run inside your brain. So you need just to think that embbrain writes to you.
 </p>
 </sect>
</xmlman>

I'm able to fetch <p> content (the long text) and <empha> content
with xmlNodeListGetString().
Making a loop bellow <sect> like:

while (node !=NULL)
        {
                if ((!xmlStrcmp(node->name, (const xmlChar *)"title")))
                {
fprintf(stdout, ".SH %s\n",toup((char *)xmlNodeListGetString(d, node->xmlChildrenNode, 1),strlen((char *)xmlNodeListGetString(d, node->xmlChildrenNode, 1))));
                }
                if ((!xmlStrcmp(node->name, (const xmlChar *)"p")))
                {
fprintf(stdout,".PP %s\n",(char *)xmlNodeListGetString(d, node->xmlChildrenNode,1));
                        node=node->xmlChildrenNode;
                }
                if ((!xmlStrcmp(node->name, (const xmlChar *)"empha")))
                {
fprintf(stdout, ".I %s\n",(char *)xmlNodeListGetString(d, node->xmlChildrenNode, 1));
                }
        node=node->next;
        }

I've got:
.SH DESCRIPTION
.PP
embbrain is a text editor. It is extremely simple to use, yet powerful enough to compete with other editors like (1) and (1). It uses a embedded tecnology to run inside your brain. So you need just to think that embbrain writes to you.

.I vi
.I emacs

That's ok because libxml uses DOM. But I'd like to have:
.SH DESCRIPTION
.PP
embbrain is a text editor. It is extremely simple to use, yet powerful enough to compete with other editors like
.I vi
(1) and
.I emacs
(1). It uses a embedded tecnology to run inside your brain. So you need just to think that embbrain writes to you.

Just like SAX interface would do. How can I position <empha> content
inside <p> content? Can I use some SAX functionality inside DOM ?
Can you please point some program/reference/article/mail_in_archive
that can answer this question ?

bests regards and thanks in advance

--

[]'s
Lucas Brasilino
brasilino recife pe gov br
http://www.recife.pe.gov.br
Emprel -        Empresa Municipal de Informatica (pt_BR)
                Municipal Computing Enterprise (en_US)
Recife - Pernambuco - Brasil
Fone: +55-81-34167078




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