[xml] node->children or node->next, pointer to a "text" node..

I'm writing from Turkey and my English very poor :( Excuse Me...

I tried libxml2. Our connections very slow. I download libxml2-2.4.16-1.rpm's (binary, both devel and lib) 
from rpmfind. I read all doc pages and xmlsoft.org pages this day morning.. I Tried your "Real Example". But 
i cannot be use this library :(

A xml file: called conf. file. No XSLT or namespace. First Paragraph..:

<?xml version="1.0" encoding="ISO8859-9"?>
                     Deneme Paketi
                <library param="1 2">
                     <desc locale="tr">
                             MPEG Encoder Librarysi.

And I parse this file with xmlParseFile.. I'm writing simple code for this test:

#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
//#include <libxml2/libxml/tree.h>
#include <regex.h>
#include <errno.h>
#include <libxml/parser.h>

int main() {
    xmlDocPtr   conf; 
    xmlNodePtr  node;
    xmlNodePtr  catMain, catProv;
    conf = xmlParseFile("../data/sample.xml");
    node = xmlDocGetRootElement(conf);
    node = node->xmlChildrenNode;
    while ( node != NULL ) {
      switch (1) {
          if (strcasecmp(node->name, "provides") == 0) {
             catProv = node;
             getAndView(node, conf);
          if (strcasecmp(node->name, "main") == 0) {
             catMain = node;
          printf("NODE: %s \n", node->name);
       node = node->next;

void getAndView(xmlNodePtr cur, xmlDocPtr doc) 
    printf("Node entry: %s ", cur->name);
    printf(" Data -> %s \n", xmlNodeListGetRawString(doc, cur, 1));
    if (cur->xmlChildrenNode != NULL) {
       getAndView(cur->xmlChildrenNode, doc);
    } else {
       if (cur->next != NULL) {
           getAndView(cur->next, doc);
       } else {

This program output is ( on not understanding lines, marked at ??? ) :

NODE: text  ???
NODE: text ???
Node entry: provides  Data ->  
Node entry: text  Data ->  ????
Node entry: library  Data -> 
Node entry: text  Data ->  ????
Node entry: desc  Data -> 
Node entry: text  Data -> MPEG Encoder Librarysi..
I'm confused. I search mail archives. FAQ's etc.. But not found (or not see) a information.. 

1. "text" nodes ?  What ?
2. Do not reached child nodes. What ?

Excuse me.. Yes, I'm a newbie for libxml and xml... 


Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

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