Sunday, 15 April 2012

visual c++ - &amp in xml - not able to httppost using CinternetSession -



visual c++ - &amp in xml - not able to httppost using CinternetSession -

i trying post xml file using tinyxml , cinternetsession.

what happens when have xml string this:

<url>https://www.google.co.in/#hl=en&amp;sugexp=les%3b&amp;gs_rn=2&amp;gs_ri=hp&amp;cp=8&amp;gs_id=2z&amp;xhr=t&amp;q=test+mail&amp;es_nrs=true&amp;pf=p&amp;tbo=d&amp;output=search&amp;sclient=psy-ab&amp;oq=test+mai&amp;gs_l=&amp;pbx=1&amp;bav=on.2,or.r_gc.r_pw.r_qf.&amp;bvm=bv.42080656,d.bmk&amp;fp=21a28671ab5b10f8&amp;biw=1024&amp;</url>

when seek post server cannot so.

text stops @ https://www.google.co.in/#hl=en

this code tried :

tixmldocument docs( c:\\data.xml" ); bool loadokay = docs.loadfile(); if ( loadokay ) { } else { tixmlprinter printer; printer.setindent("\t"); docs.accept( &printer ); docs.print(); cstring urlpostdata = printer.cstr(); #define max_read_buffer 102400 cstring strheaders =_t("content-type: application/x-www-form-urlencoded"); cstring strformdata = _t("data=<?xml version=\"1.0\"?><urldata>"+urlpostdata+"</urldata>"); //afxmessagebox(strformdata); // here got msgbox "&amp" in data, while posting fails. cinternetsession session; session.setoption(internet_option_connect_timeout,10000); session.setoption(internet_option_connect_retries, 3); chttpconnection* pconnection = session.gethttpconnection(_t("xxx.xxx.xxx.x")); chttpfile* pfile = pconnection->openrequest(chttpconnection::http_verb_post, _t("/wintest/testservlet?")); bool result = pfile->sendrequest(strheaders, (lpvoid)(lpctstr)strformdata, strformdata.getlength()); dword dwerror; pfile->queryinfostatuscode(dwerror); if(dwerror==200) { afxmessagebox("data posted"); } }

my xml file is

<?xml version="1.0" encoding="utf-8"?> <application name="assignments"> <starttime>11/02/2013 16:27:14</starttime> </application>

xml visual-c++ xmlhttprequest http-post tinyxml

No comments:

Post a Comment