XML Document -> Whitespaces Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ONeill
I live to help wx-kind
I live to help wx-kind
Posts: 152
Joined: Wed Oct 04, 2006 12:51 pm

XML Document -> Whitespaces

Post by ONeill » Wed Jun 04, 2008 1:25 pm

Hello,

i am writing a XML File using wxXMLDocument.
If i try to add a string like "He llo". The Ouput is: "He llo" I want to keep the spaces. So before writing in the XML File, i replace all " " with "&#160", but the XML class replaces the "&" automaticly with "&amp".

How can i support more spaces in row, or how can i prevent the class to replace the "&"?

Thanks for help!

protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol » Wed Jun 04, 2008 2:44 pm

Don't forget to put the semi-colon after the code

Code: Select all

He llo

or

<![CDATA[He llo]]>
If that doesn't work just wrap it in CDATA, which may be better in the end if you don't want the text to be interpreted by the XML parser.

best regards.
/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!

ONeill
I live to help wx-kind
I live to help wx-kind
Posts: 152
Joined: Wed Oct 04, 2006 12:51 pm

Post by ONeill » Tue Jun 10, 2008 8:11 am

How can i disable the replacement from "<" with "<" by the XMLDocument class?

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Tue Jun 10, 2008 8:29 am

How can i disable the replacement from "<" with "<" by the XMLDocument class?
If you want to have valid XML output, you do not want to prevent this. Just try to parse text which has that symbol in e.g. a string parameter like

Code: Select all

<node text="<" />
This gives an error as it is not allowed to have unescaped valid XML start / end delimiters.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

ONeill
I live to help wx-kind
I live to help wx-kind
Posts: 152
Joined: Wed Oct 04, 2006 12:51 pm

Post by ONeill » Tue Jun 10, 2008 8:47 am

Yey, but i don't want to write the "<" as a string, because i want to use the CDATA tag.

So if i save a node with the CDATA Tag, i'll get

Code: Select all

<SURNAME><![CDATA[Mustermann]]></SURNAME>
and if i read the xml file again, i, as expected, am getting the CDATA tag as a string, but i want to use the CDATA as a tag, so i can write whitespaces and linebreaks into the xmlDocument.

wxXMLDocument is able to parse the CDATA tag, but i didn't find an option to use this tag with wxXMLDocumend/wxXMLNode,...!

EDIT:

Oh, i saw the "wxXML_CDATA_SECTION_NODE" tag. i will look at it and i think i can solve my problem that way :)

Post Reply