rupali bhore
unread,Mar 22, 2017, 8:16:20 AM3/22/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TinyXML++
Hello Sir/ Mam,
I am trying to optimize time require for XML parsing. What ever little knowledge I have about XML parsing according to that I did one program (in which it is only fetching data between tags by simple file handling concepts and giving me much optimize output as compare to pugi XML. I tried it for filesize 1MB ) So my question is can I called it as a complete XML parser?? Or what are those requirements which should be fulfilled by one XML parser??Cause I think this might be done some where before.
this is my code
***********************************************************************
#include<stdio.h>
#include<iostream.h>
#include<string.h>
#include<time.h>
void main()
{
clock_t start,end;
double cpu_time_used;
int i;
start = clock();
FILE *fp,*wfp;
char text[300],c,stk[5][5],tempTag[10],value[20],closeTag,flag,fClose,sStart,tagNo=1;
int j,n,top=-1;
fp=fopen("xmll.txt","r");
wfp=fopen("xml.txt","w");
while(strlen(fgets(text,300,fp))!=0)
{
closeTag=0; flag=0;
for(i=0;i<strlen(text);i++)
{
if(text[i]=='>')
{
closeTag++;
if(flag==0)
{
fClose=i;
flag=1;
}
}
// printf("\nFlag = %d \t text[i]= %c \t i = %d",flag,text[i],i);
if(flag==1 && text[i]=='<')
{
sStart=i;
}
}
if(closeTag==2)
{
/* printf("\n%s",text);
printf("\tfclose = %d",fClose);
printf("\t sStart = %d",sStart);*/
j=0;
for(i=(fClose+1);i<sStart;i++)
{
value[j]=text[i];
j++;
}
value[j]='\0';
switch(tagNo){
case 1: fputs(value,wfp);fputs("\n",wfp);tagNo++;break;
case 2: fputs(value,wfp);fputs("\n",wfp);tagNo++;break;
case 3: fputs(value,wfp);fputs("\n",wfp);tagNo++;break;
case 4: fputs(value,wfp);fputs("\n",wfp);tagNo++;break;
case 5: fputs(value,wfp);fputs("\n",wfp);tagNo++;break;
case 6: fputs(value,wfp);fputs("\n",wfp);tagNo=1;fputs("\n\n",wfp);;break;
}
}
}
end=clock();
cpu_time_used=((double) (end-start))/CLOCKS_PER_SEC;
cout<<cpu_time_used;
}
**********************************************************************
XML input file
<book>
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with XML.</description>
</book>
<book>
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect bachildhood to become queen of the world.</description>
</book>
<book>
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology</description>
</book>
<book>
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse England, the mysterious for the inhabitants of London. Sequel to Maeve Ascendant.</description>
</book>
<book>
<author>Corets, Eva</author>
<title>The Sundered Grail</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-09-10</publish_date>
<description>The two daughters of Maeve, half-sisters, battle one another for control of England. Sequel to Oberon's Legacy.</description>
</book>
<book>
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-09-02</publish_date>
<description>When Carla meets Paers fly as feathers get ruffled.</description>
</book>
<book>
<author>Thurman, Paula</author>
<title>Splish Splash</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-11-02</publish_date>
<description>A deep sea diver finds true love twenty thousand leagues beneath the sea.</description>
</book>
<book>
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
<price>4.95</price>
<publish_date>2000-12-06</publish_date>
<description>An anthology of horror stories about roaches,centipedes, scorpions and other insects.</description>
</book>
<book>
<author>Kress, Peter</author>
<title>Paradox Lost</title>
<genre>Science Fiction</genre>
<price>6.95</price>
<publish_date>2000-11-02</publish_date>
<description>After an inadvertant trip through a HeisenbergUncertainty Device, James Salway discovers the problems of being quantum.</description>
</book>
<book>
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-09</publish_date>
<description>Microsoft's .NET initiative is explored in detail in this deep programmer's reference.</description>
</book>
<book>
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-01</publish_date>
<description>The Microsoft MSXML3 parser is covered in detail, wi</description>
</book>