Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I have a data like this :-
 
<pre lang="text"><string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;DataCaptureSettings&gt;&lt;ModuleSettings&gt;&lt;capture_local_dir&gt;c:\&lt;/capture_local_dir&gt;&lt;capture_log_dir&gt;c:\log&lt;/capture_log_dir&gt;&lt;capture_log_level&gt;debug&lt;/capture_log_level&gt;&lt;capture_request_interval&gt;2&lt;/capture_request_interval&gt;&lt;capture_connection_interval&gt;2&lt;/capture_connection_interval&gt;&lt;smtp_server_name&gt;n1&lt;/smtp_server_name&gt;&lt;smtp_server_port&gt;80&lt;/smtp_server_port&gt;&lt;/ModuleSettings&gt;&lt;Machines&gt;&lt;Machine&gt;&lt;MachineId&gt;0022&lt;/MachineId&gt;&lt;AccountId&gt;1&lt;/AccountId&gt;&lt;location_code&gt;LOC_100&lt;/location_code&gt;&lt;Make&gt;Nipro&lt;/Make&gt;&lt;Model&gt;Model1&lt;/Model&gt;&lt;SerialNumber&gt;126649E&lt;/SerialNumber&gt;&lt;IpAddress&gt;10.10.10.10&lt;/IpAddress&gt;&lt;Port&gt;80&lt;/Port&gt;&lt;/Machine&gt;&lt;Machine&gt;&lt;MachineId&gt;3000&lt;/MachineId&gt;&lt;AccountId&gt;1&lt;/AccountId&gt;&lt;location_code&gt;LOC_100&lt;/location_code&gt;&lt;Make&gt;Make3&lt;/Make&gt;&lt;Model&gt;Model3&lt;/Model&gt;&lt;SerialNumber&gt;SN3&lt;/SerialNumber&gt;&lt;IpAddress&gt;30.30.30.30&lt;/IpAddress&gt;&lt;Port&gt;80&lt;/Port&gt;&lt;/Machine&gt;&lt;/Machines&gt;&lt;/DataCaptureSettings&gt;</string> </pre>
 
With some modification i want a data like this:-
Can anyone please tell what to do?
 

<pre lang="text"><?xml version="1.0" encoding="UTF-8"?><DataCaptureSesstings><ModuleSettings><account_id name="id">1</account_id><capture_local_dir>c:</capture_local_dir><capture_log_dir>c:log</capture_log_dir><capture_log_level>debug</capture_log_level><capture_request_interval>2</capture_request_interval><capture_connection_interval>2</capture_connection_interval><smtp_server_name>n1</smtp_server_name><smtp_server_port>80</smtp_server_port><smtp_email_sender>s1</smtp_email_sender><smtp_email_sender_password>p1</smtp_email_sender_password></ModuleSettings><MachineList><Machine><MachineId>0022</MachineId><Make>Make1</Make><Model>Model1</Model><SerialNumber>SN1</SerialNumber><IpAddress>10.10.10.10</IpAddress><Port>80</Port></Machine><Machine><MachineId>3000</MachineId><Make>Make3</Make><Model>Model3</Model><SerialNumber>SN3</SerialNumber><IpAddress>30.30.30.30</IpAddress><Port>80</Port></Machine></MachineList></DataCaptureSesstings> </pre>
Posted 17-Oct-12 21:54pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If the string does not contain other XML entities than those for reserved characters and no Unicode points, you may use the CStringT class to replace the entities by characters:
CString ReplaceEntities(LPCTSTR lpszHtml)
{
    CString s(lpszHtml);
    s.Replace(_T("&gt;"), _T(">"));
    s.Replace(_T("&lt;"), _T("<"));
    s.Replace(_T("&quot;"), _T("\""));
    s.Replace(_T("&apos;"), _T("'"));
    s.Replace(_T("&amp;"), _T("&")); // Perform this replacement as the last one
    return s;
}
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 290
1 Jochen Arndt 150
2 Kornfeld Eliyahu Peter 149
3 PIEBALDconsult 110
4 Richard MacCutchan 105
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 18 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100