What is that "xstrm" variable?
What is that "xstrm" variable?
Qt Code:
f.open(IO_WriteOnly);To copy to clipboard, switch view to plain text mode
Regards
Do you see where the problem is?Originally Posted by mickey
yes it was the error; but if I use .read() my app doesn't respond....
I coded this also:
Qt Code:
f.open(IO_ReadOnly | IO_WriteOnly); //QDomText t1 = doc.createTextNode("hello"); //with this ok tag1.appendChild(t1);To copy to clipboard, switch view to plain text modeafter this in my file I found:Qt Code:
xstrm << "hello\n"; }To copy to clipboard, switch view to plain text mode
why? "hello" is right...with "QDomText t1 = doc.createTextNode(plainText)" I'm trying to insert again "hello" in the file.....thanks
Regards
I guess that QTextStream just reads the file from the current position, try adding "f.reset()" before xstrm.readLine().
ok now it seems work with read() properly. but a strange thing happen in the file after write; the second part of file appear in a wrong way..
Qt Code:
<Light0 pos="4 1 4 1" //wrongTo copy to clipboard, switch view to plain text modeWhy this? thanksQt Code:
<Light0 pos="4 1 4 1" //rightTo copy to clipboard, switch view to plain text mode
Regards
Maybe because you create a text node (i.e. text that is between tags)?Originally Posted by mickey
Could you describe what are you trying to achieve?
like above I'm trying to create a file; in that I like put "hello" with class.XML (this work); then I like put the contentent of file (in this case "hello") inside two tag <Plain> </plain>;Originally Posted by mickey
that doesn't work (but it works using
Qt Code:
To copy to clipboard, switch view to plain text mode
other thing: using f.open(IO_ReadOnly | IO_WriteOnly); when I save file the text is append at the end...why? with only IO_WriteOnly the file is destroyed everytime (I want this)...thanks
then I need put the
content of strm between tag PLAIN. How this?Qt Code:
To copy to clipboard, switch view to plain text mode
Last edited by mickey; 3rd July 2006 at 18:36.
Regards
If xstrm contains text everything is OK --- < & > were just converted to entities, but if xstrm contains text and XML tags, then you can't use a text node to add it to the document.Originally Posted by mickey
Consider this fragment of XML document:Here you have 4 nodes. Three text nodes ("xxx", "yyy" and "zzz") and element node "tag". You can't use a single node instead of 4 nodes....
xxx
<tag>yyy</tag>
zzz
...
Why do you need to read data from that file? Maybe you could create a DOM document and then just write it to a file?
ok I'll reformulate my problem:
this produce a file:Qt Code:
f.open(IO_WriteOnly); doc.appendChild (root); root.appendChild(tag1); xstrm << xml;To copy to clipboard, switch view to plain text mode
hello is produced by calling Class.Write (see previous post). I'd like to put hello (what the write() do) in the place of 'HI'; i don't know how to do this...thanksQt Code:
hello <!DOCTYPE level.xml> <le> <PLAIN Property> HI </PLAIN Property> </le>To copy to clipboard, switch view to plain text mode
Regards
OK, so first you must capture the output generated by Class.Write.Originally Posted by mickey
Something like: should be enough.
And then:Qt Code:
... tag1.appendChild( t1 );To copy to clipboard, switch view to plain text mode
PS. AFAIK "PLAIN Property" is not a valid name of an element in XML.
Hi, without repeat all code before with your solution I've got the prevoius problem inside the file:
But if I use my prevoius code works (but i can put what Write() do only before tag PLAIN and not inside it....Qt Code:
<Light0 pos="4 1 4 1" //wrongTo copy to clipboard, switch view to plain text mode
Qt Code:
.............................. .............To copy to clipboard, switch view to plain text mode
Regards
Because you add this as text. That's how a text which contains <, > and " looks like in XML.Originally Posted by mickey
sorry, but is it possible avoid this??
Regards
It depends on what you are trying to achieve. Does Class.Write() output XML or plain text?Originally Posted by mickey
What do you need QDomDocument for? Just to place the Class.Write() output between tags?
Bookmarks