
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
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();
}
if(!xmlfile.open( QIODevice::ReadOnly ) ) {
out....
}
QString errorStr;
int errorLine;
int errorColumn;
QDomDocument doc("http://www.pulitzer.ch/2005/PuliCMS/1.0");
if (!doc.setContent(&xmlfile,true, &errorStr, &errorLine, &errorColumn)) {
QString error = (QString("Parse error at line %1, column %2:\n%3")
.arg(errorLine)
.arg(errorColumn)
.arg(errorStr) );
ErrorConfig(error);
xmlfile.close();
}
To copy to clipboard, switch view to plain text mode
the best way i think to make a similar php class on qt...
php 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);
}
}
/* 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) {
if (is_file($frag)) {
$frag = @file_get_contents($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) {
return preg_replace_callback("/(<\?php|<\?)(.*?)\?>/si",create_function("","return '';"),$string);
}
function utf($string) {
return Multi_Language::utf8_to_unicode($string);
}
}
To copy to clipboard, switch view to plain text mode
but can i open qtextstreams on dom?
if (! doc.setContent(qtextstreams...) ) {
if (! doc.setContent(qtextstreams...) ) {
To copy to clipboard, switch view to plain text mode
Bookmarks