QDomImplementation real dom Document;
i wand to write xml doc on QDomDocument not entyti ....
on line to line the doc is so:
Code:
xml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
xml.append("<cms:root xmlns:cms=\"http://www.pulitzer.ch/2005/PuliCMS/1.0\">");
xml.append("<cms:page la=\"it\">");
xml.append(desc_it->GetXMLTag());
xml.append("</cms:page>");
xml.append("</cms:root>");
qDebug() << "### xml result1 " << stayutf8;
and on a real QDomDocument.... Manual say so:
Code:
root.setAttribute("xmlns:s","http://www.pulitzer.ch/2005/shop/shema/1.0/");
root.setAttribute("xmlns:cms","http://www.pulitzer.ch/2005/PuliCMS/1.0/");
doc.appendChild(root);
page.setAttribute("xmlns:cms","http://www.pulitzer.ch/2005/PuliCMS/1.0/");
page.setAttribute("la","it");
root.appendChild(page);
qDebug() << "### xml result2 " << xml;
on php5 and qt all dom function is same but new domdocument no....
php = $dom = new DOMDocument('1.0', 'utf-8') and become a clean first line...
qt no why?
how to become a clean line <?xml version=\"1.0\" encoding=\"utf-8\"?> so tidy xml dont clean?
Re: QDomImplementation real dom Document;
Quote:
Originally Posted by patrik08
on php5 and qt all dom function is same but new domdocument no....
php = $dom = new DOMDocument('1.0', 'utf-8') and become a clean first line...
qt no why?
Because DOM Level 2 specification does not specify the constructor of Document (since it's an interface, not a class).
Quote:
Originally Posted by patrik08
how to become a clean line <?xml version=\"1.0\" encoding=\"utf-8\"?> so tidy xml dont clean?
As usual in Qt --- with only a few lines of code:
Code:
#include <QDomDocument>
#include <QtDebug>
int main()
{
doc.appendChild( header );
doc.appendChild( root );
qDebug() << doc.toString();
return 0;
}
Quote:
$ ./xml
"<?xml version="1.0"?>
<test/>
"
Re: QDomImplementation real dom Document;
and QDomDocumentFragment so helpfull is the same?
Code:
page.setAttribute("xmlns:cms","http://www.pulitzer.ch/2005/PuliCMS/1.0/");
page.setAttribute("la","it");
root.appendChild(page);
Re: QDomImplementation real dom Document;
Quote:
Originally Posted by patrik08
and QDomDocumentFragment so helpfull is the same?
I'm not sure what you mean.
Quote:
Originally Posted by patrik08
(const QDomDocumentFragment)(desc_it->GetXMLTag())
What does GetXMLTag() return? It seems that you are doing something dangerous here.
Re: QDomImplementation real dom Document;
Quote:
Originally Posted by jacek
I'm not sure what you mean.
What does GetXMLTag() return? It seems that you are doing something dangerous here.
Fragments of xml return.... tree or only </nocode>
I wand to attach piece of fragment to other... to build on file...
Is a imb db2 to -> mysql transfer file and back 2MB adress rysinc...
Re: QDomImplementation real dom Document;
Quote:
Originally Posted by patrik08
Fragments of xml return....
If that method returns QDomDocumentFragment, then why do you need a cast?
Re: QDomImplementation real dom Document;
Quote:
Originally Posted by jacek
If that method returns QDomDocumentFragment, then why do you need a cast?
why? is a existing file ... trasformed to qstring and replace <? xml...>
wenn i open the file on QDomDocument ... on error.... i must return a empyty dom?
on qstring on error read i return a <nullnode/> qstring...
qt code
Code:
out....
}
int errorLine;
int errorColumn;
QDomDocument doc
("http://www.pulitzer.ch/2005/PuliCMS/1.0");
if (!doc.setContent(&xmlfile,true, &errorStr, &errorLine, &errorColumn)) {
.arg(errorLine)
.arg(errorColumn)
.arg(errorStr) );
ErrorConfig(error);
xmlfile.close();
}
the best way i think to make a similar php class on qt...
php code
Code:
/* Aggregate moore xml file to one or insert xml fragment */
class XML extends DOMDocument {
function __construct () {
parent::__construct ();
}
function __destruct() {
parent::__destruct();
}
/* function similar from createDocumentFragment but enter xml file or pure xml frags */
function appendXML_or_File($node,$frag) {
}
$tmpdoc = new self('1.0', 'utf-8');
$tmpdoc->loadXML("<dummyroot>".$this->Remove_Version($frag)."</dummyroot>")
or Error_Manager
::msg('Error on fragment not possibel to insert xml Fragment!'.htmlentities($frag, ENT_QUOTES
),__FILE__,__LINE__); $newnode = $node->ownerDocument->importNode($tmpdoc->documentElement,true);
$child = $newnode->firstChild;
while ($child) {
$nextChild = $child->nextSibling;
$node->appendChild($child);
$child = $nextChild;
}
}
/* remove php code or xml header ..... */
function Remove_Version($string) {
}
function utf($string) {
return Multi_Language::utf8_to_unicode($string);
}
}
but can i open qtextstreams on dom?
Code:
if (! doc.setContent(qtextstreams...) ) {
Re: QDomImplementation real dom Document;
Quote:
Originally Posted by patrik08
why? is a existing file ... trasformed to qstring and replace <? xml...>
I was asking about this:
Quote:
(const QDomDocumentFragment)(desc_it->GetXMLTag())
Either you don't need it or you do something Bad.
Quote:
Originally Posted by patrik08
but can i open qtextstreams on dom?
Not directly, but you can try:
Code:
doc.setContent( stream.readAll() );
Re: QDomDocumentFragment is not !isDocumentFragment()
The fragment is not fragment!
Qtextstream "<samplenode/>" readAll() return a false QDomDocument
and fragment give a false isDocumentFragment() why?
Code:
#include <QtDebug>
#include <QDebug>
#include <QObject>
#include <QSettings>
#include <QErrorMessage>
#include <QProcess>
#include <QDomDocument>
#include <QDomElement>
#include <QStringList>
#include <QDir>
#include <QDomDocumentFragment>
#include <QDomImplementation>
#include <QMessageBox>
int main(int argc, char *argv[]) {
QString filexmleternal
= "./qtpage.xml";
bool is_fi = false;
QFile xmlfile
(filexmleternal
);
/* stay false ! */
}
if (dom_external.setContent(&xmlfile)) {
is_fi = true;
}
if (!is_fi) {
qDebug() << "External file not loadet!";
} else {
qDebug() << "External file is super!! loadet!";
frag.appendChild(dom_external);
if (!frag.isDocumentFragment()) {
qDebug() << "Is not a fragment !!!";
}
}
/* external file end */
/* new qdom to insert external ... */
doc.appendChild( header );
doc.appendChild( root );
if (is_fi) {
//////big.appendChild(frag); /* not insert */
}
root.appendChild( big );
/////QDomNode::isDocumentFragment ()
qDebug() << doc.toString();
return 0;
};
pro file...
Code:
TEMPLATE = app console
TARGET +=
DEPENDPATH += .
INCLUDEPATH += .
win32:debug { CONFIG = console }
CONFIG += qt warn_on release
QT += xml
# Input
SOURCES += main.cpp
Re: QDomDocumentFragment is not !isDocumentFragment()
Quote:
Originally Posted by patrik08
fragment give a false isDocumentFragment() why?
Probably it's a bug, use QDomDocument::createDocumentFragment() to create document fragments.
PS. If you post code, please, post only relevant part. 3/4 of your example has nothing to do with QDomDocumentFragment.
Re: QDomImplementation real dom Document;
is solved so.... and fragment not run!
make a node from external root and .toElement(); after big.appendChild(extase);
to other node....
Code:
int main(int argc, char *argv[]) {
QString filexmleternal
= "./qtpage.xml";
bool is_fi = false;
QFile xmlfile
(filexmleternal
);
/* stay false ! */
}
is_fi = dom_external.setContent(&xmlfile);
QDomElement root_extern
= dom_external.
documentElement();
QDomNode externxml
= root_extern.
firstChild();
QDomNode externxml_2
= dom_external.
importNode(externxml,
true);
if (!is_fi) {
qDebug() << "External file not loadet!";
} else {
qDebug() << "External file is super!! loadet!";
}
doc.appendChild( header );
doc.appendChild( root );
big.appendChild(extase); /* the external file not from fragment */
root.appendChild( big );
qDebug() << doc.toString();
return 0;
};
Re: QDomImplementation real dom Document;
Quote:
Originally Posted by
jacek
Because DOM Level 2 specification does not specify the constructor of Document (since it's an interface, not a class).
As usual in Qt --- with only a few lines of code:
Code:
#include <QDomDocument>
#include <QtDebug>
int main()
{
doc.appendChild( header );
doc.appendChild( root );
qDebug() << doc.toString();
return 0;
}
Thanks, this helps me!