Hey.. i am a newbie.. so please be patient..
using xml and qt for first time.
i am trying to read a xml using a dom reader, but it shows a error---
MY XML---
<?xml version="1.0" encoding="UTF-8"?>
-<Summary>
<no_of_blank_spaces>13</no_of_blank_spaces>
<no_of_blank_lines>8</no_of_blank_lines>
<no_of_words>16</no_of_words>
<no_of_lines_starting_with_hash>2</no_of_lines_starting_with_hash>
</Summary>
<?xml version="1.0" encoding="UTF-8"?>
-<Summary>
<no_of_blank_spaces>13</no_of_blank_spaces>
<no_of_blank_lines>8</no_of_blank_lines>
<no_of_words>16</no_of_words>
<no_of_lines_starting_with_hash>2</no_of_lines_starting_with_hash>
</Summary>
To copy to clipboard, switch view to plain text mode
MY DOM READER CODE---
void DOMReader
::parseFile(QString fileName
) {
//file.open(QIODevice::ReadOnly);
qDebug() << "Not able to open the file";
return;
}
qDebug()<<"///////////////////////////"<<file.isOpen();----> [B]IT SHOWS OPEN here.[/B]
int errLine;
int errCol;
if (!doc.setContent(&file,false,&errMsg,&errLine,&errCol)) {
qDebug() << "errMsg : " << errMsg;
qDebug() << "errLine : " << errLine;
qDebug() << "errCol : " << errCol;
qDebug() << "Error in XML File format" <<endl;
return;
}
if (root.tagName() != "Summary") {
qDebug() << "Error in root" << endl;
return;
}
processRoot(root);
return;
}
{
qDebug()<< "***********in dom*********" << endl;
}
void DOMReader::parseFile(QString fileName) {
QFile file(fileName);
//file.open(QIODevice::ReadOnly);
if (!file.open(QIODevice::ReadOnly)) {
qDebug() << "Not able to open the file";
return;
}
qDebug()<<"///////////////////////////"<<file.isOpen();----> [B]IT SHOWS OPEN here.[/B]
QString errMsg;
int errLine;
int errCol;
QDomDocument doc;
if (!doc.setContent(&file,false,&errMsg,&errLine,&errCol)) {
qDebug() << "errMsg : " << errMsg;
qDebug() << "errLine : " << errLine;
qDebug() << "errCol : " << errCol;
qDebug() << "Error in XML File format" <<endl;
return;
}
QDomElement root = doc.documentElement();
if (root.tagName() != "Summary") {
qDebug() << "Error in root" << endl;
return;
}
processRoot(root);
return;
}
void DOMReader::processRoot(QDomElement root)
{
qDebug()<< "***********in dom*********" << endl;
}
To copy to clipboard, switch view to plain text mode
I am getting a error as--:
errorMSg:-"unexpected end of file"
errLINe:1
errCol:1
Error in XML Format..
kindly help me through..
Bookmarks