Results 1 to 6 of 6

Thread: innerText in an XML file

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default innerText in an XML file

    hello, with C# xml library I'm reading a xml file that contains this:
    "http://www.ggggg/fff&hello";
    Qt Code:
    1. While (xmlReader) {
    2. if (link)
    3. string link = reader.Value; //link now hasn't "amp;"
    4. }
    5. XMLWriter my_xml_writer;
    6. myTag.InnerText = link; //here problem
    7. write_to_file_as_xml
    To copy to clipboard, switch view to plain text mode 
    Above, innerText take the right thing(without "amp;") but the output file has "&". I note (debugging) that myTag has also one other property: innerXML that it contains the "&".
    I guess, xml library, seeing a '&' add automatically a 'amp;' after &;
    I need to read from a file that has "&" and write to output file as "&" only. Is there a solution, please?

    thanks.
    Last edited by mickey; 22nd January 2008 at 17:13.
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: innerText in an XML file

    First I would check if you can disable automatic entity encoding in XMLWriter.

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: innerText in an XML file

    Quote Originally Posted by jacek View Post
    First I would check if you can disable automatic entity encoding in XMLWriter.
    I don't find any thing like that. There are several properties. I see that I can change encoding as:UTF, ASCII....but to be sincer, I don't know what look......However I have the same problem (I guess) when I have "myTag.innerText = "<div> </div>" and when I write it on the output file, I see &lt;div&gt;......Any other suggest? thanks.
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: innerText in an XML file

    Quote Originally Posted by mickey View Post
    However I have the same problem (I guess) when I have "myTag.innerText = "<div> </div>" and when I write it on the output file, I see &lt;div&gt;
    That's how it should behave. You are adding text, not XML snippet --- try innerXml.

    As for the entity references, you could try to reimplement one of the WriteXxx methods of the XmlWriter (I hope you realize that & isn't allowed in XML).

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: innerText in an XML file

    I can't understand why does the parser change it, if I'd like insert into a node as text the char '<' ?
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: innerText in an XML file

    Quote Originally Posted by mickey View Post
    if I'd like insert into a node as text the char '<' ?
    You can't insert '<' into an XML document just like that, because it has special meaning --- it's a sign for a parser that a tag starts. That's why there are character entities in XML. For a parser &lt; is exactly the same thing as character < (of course this means that you can't use & in XML documents and you have to use &amp; instead).

Similar Threads

  1. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  2. Replies: 2
    Last Post: 8th November 2007, 20:15
  3. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  4. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  5. Sending Binary File with QFTP
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 7th March 2007, 18:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.