[xml] xmlDocDump will lost some part



Hi everybody!

I'm a newbie of libxml2.I meet a strange problem.I post them below as html format,and I attach the project to save the time of yours.

the only change of right.xml is that I removed one line from wrong.xml.But the xmlDocDump will dump the right.xml without any problem,while the wrong.xml will lost a line.And I and a line to the wrong.xml,such as additioanl <region id="Image2" ........ />,the result is correct too.

I have no idea about this,is that I missused xmlTextReaderRead???

Any suggestion is appreciated,Thanks!

[clgao paradise temp]$ more right.xml
<smil>
  <head>
    <layout>
      <root-layout height="200" width="176"/>
      <region id="Image" left="5%" top="5%" height="95%" width="95%" fit="scroll"/>
    </layout>
  </head>

  <body>
    <par dur="20000ms">
      <video src="" region="Image"/>
      <text src="" region="Text"/>
    </par>
    <par dur="2000ms">
      <img src="" region="Image"/>
      <text src="" region="Text"/>
    </par>
  </body>
</smil>
[clgao paradise temp]$ more wrong.xml
<smil>
  <head>
    <layout>
      <root-layout height="200" width="176"/>
      <region id="Image" left="5%" top="5%" height="95%" width="95%" fit="scroll"/>
      <region id="Text" left="5%" top="5%" height="95%" width="95%" fit="scroll"/>
    </layout>
  </head>

  <body>
    <par dur="20000ms">
      <video src="" region="Image"/>
      <text src="" region="Text"/>
    </par>
    <par dur="2000ms">
      <img src="" region="Image"/>
      <text src="" region="Text"/>
    </par>
  </body>
</smil>
[clgao paradise temp]$ ./temp right.xml
<?xml version="1.0"?>
<smil>
  <head>
    <layout>
      <root-layout height="200" width="176"/>
      <region id="Image" left="5%" top="5%" height="95%" width="95%" fit="scroll"/>
    </layout>
  </head>

  <body>
    <par dur="20000ms">
      <video src="" region="Image"/>
      <text src="" region="Text"/>
    </par>
    <par dur="2000ms">
      <img src="" region="Image"/>
      <text src="" region="Text"/>
    </par>
  </body>
</smil>
[clgao paradise temp]$ ./temp wrong.xml
<?xml version="1.0"?>
<smil>
  <head>
    <layout>
      <root-layout height="200" width="176"/>
      <region id="Image" left="5%" top="5%" height="95%" width="95%" fit="scroll"/>
      <region id="Text" left="5%" top="5%" height="95%" width="95%" fit="scroll"/>
    </layout>
  </head>

  <body>
    <par dur="20000ms">
      <video src="" region="Image"/>
      <text src="" region="Text"/>
    </par>
    <par dur="2000ms">
      <img src="" region="Image"/>
      </par></body></smil>
[clgao paradise temp]$ more temp.c
#include <memory.h>
#include <stdio.h>
#include <string.h>
#include <libxml/xmlreader.h>

int main(int argc,const char* argv[])
{
     xmlTextReaderPtr reader;
     xmlDocPtr doc = NULL;
    
     if(argc != 2)
     {
          printf("usage : temp file1\n");
          exit(0);
     }

     LIBXML_TEST_VERSION;
    
     reader = xmlReaderForFile(argv[1],NULL,0);
     if(!reader)
     {
          printf("can't open file %s\n",argv[1]);
          exit(0);
     }

     if((1 != xmlTextReaderRead(reader))
        || !(doc = xmlTextReaderCurrentDoc(reader)))
     {
          printf("create doc failed\n");
          exit(0);
     }

     xmlDocDump(stdout,doc);

     xmlCleanupParser();

     exit(0);
     return 0;
}
[clgao paradise temp]$



Attachment: Temp.zip
Description: Zip archive



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