Note that there are some explanatory texts on larger screens.

plurals
  1. PO&amp in xml - not able to httppost using CinternetSession
    primarykey
    data
    text
    <p>I am trying to post an xml file using tinyxml and CInternetSession.</p> <p>What happens is when I have a xml string like this:</p> <pre><code>&lt;url&gt;https://www.google.co.in/#hl=en&amp;amp;sugexp=les%3B&amp;amp;gs_rn=2&amp;amp;gs_ri=hp&amp;amp;cp=8&amp;amp;gs_id=2z&amp;amp;xhr=t&amp;amp;q=test+mail&amp;amp;es_nrs=true&amp;amp;pf=p&amp;amp;tbo=d&amp;amp;output=search&amp;amp;sclient=psy-ab&amp;amp;oq=test+mai&amp;amp;gs_l=&amp;amp;pbx=1&amp;amp;bav=on.2,or.r_gc.r_pw.r_qf.&amp;amp;bvm=bv.42080656,d.bmk&amp;amp;fp=21a28671ab5b10f8&amp;amp;biw=1024&amp;amp;&lt;/url&gt; </code></pre> <p>when I try to post this to the server I cannot do so.</p> <p>Text stops at <code>https://www.google.co.in/#hl=en</code></p> <p>This is the code I tried :</p> <pre><code> TiXmlDocument docs( C:\\data.xml" ); bool loadOkay = docs.LoadFile(); if ( loadOkay ) { } else { TiXmlPrinter printer; printer.SetIndent("\t"); docs.Accept( &amp;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=&lt;?xml version=\"1.0\"?&gt;&lt;urldata&gt;"+URLpostdata+"&lt;/urldata&gt;"); //AfxMessageBox(strFormData); // Here i got a msgbox with "&amp;amp" in data, but while posting it 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-&gt;OpenRequest(CHttpConnection::HTTP_VERB_POST, _T("/WinTest/TestServlet?")); BOOL result = pFile-&gt;SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength()); DWORD dwError; pFile-&gt;QueryInfoStatusCode(dwError); if(dwError==200) { AfxMessageBox("Data was successfully posted"); } } </code></pre> <p>my XML file is</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;application name="assignments"&gt; &lt;starttime&gt;11/02/2013 16:27:14&lt;/starttime&gt; &lt;/application&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload