Re: [Quickfix-developers] toXML function for 'special XML characters'
Brought to you by:
orenmnero
From: Oren M. <or...@qu...> - 2004-09-11 16:24:55
|
Hmm. Yeah we should be handling this. Although I wonder if maybe we should just be putting the values into a CDATA section? --oren On Sep 10, 2004, at 7:53 AM, Van Gelder Eddy (KATO 2) wrote: > QuickFIX Documentation: > http://www.quickfixengine.org/quickfix/doc/html/index.html > QuickFIX FAQ: > http://www.quickfixengine.org/wikifix/index.php?QuickFixFAQ > QuickFIX Support: http://www.quickfixengine.org/services.html > > Hi Oren, > > after receiving a message in the Fixengine I use the toXML function to > obtain the XML version of the message and then perform XSLT to > transform to our internal format. > > for some special XML characters I had to add a bit of code in the > Message.cpp to transform > > & in & > < in < > " in " > > otherwise the generated XML is not OK. > > <field name="Text" number="58" value="PRICE < 100"/> > > should be > > <field name="Text" number="58" value="PRICE < 100"/> > > > is this somthing that you would want to put in the base quickfix > release ? > > Rgds, > Eddy > > > > std::string Message::toXMLFields(const FieldMap& fields, int space) > const > { QF_STACK_PUSH(Message::toXMLFields) > > std::stringstream stream; > FieldMap::iterator i; > std::string name; > for(i = fields.begin(); i != fields.end(); ++i) > { > int field = i->first; > std::string value = i->second.getString(); > > ********************* > size_t lookHere = 0; > size_t foundHere; > while ((foundHere = value.find("&",lookHere)) > != std::string::npos) { > value.replace(foundHere, 1, "&"); > lookHere = foundHere + 5; > } > lookHere = 0; > while ((foundHere = value.find("<",lookHere)) > != std::string::npos) { > value.replace(foundHere, 1, "<"); > lookHere = foundHere + 4; > } > lookHere = 0; > while ((foundHere = value.find('"',lookHere)) > != std::string::npos) { > value.replace(foundHere, 1, """); > lookHere = foundHere + 6; > } > ****************** > > > ------------------------------------------------------- > This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 > Project Admins to receive an Apple iPod Mini FREE for your judgement on > who ports your project to Linux PPC the best. Sponsored by IBM. > Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php > _______________________________________________ > Quickfix-developers mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-developers > |