本文介绍了格式化后如何获取所需数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have a data like this :-
<pre lang="text"><string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"><?xml version="1.0" encoding="UTF-8"?><DataCaptureSettings><ModuleSettings><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></ModuleSettings><Machines><Machine><MachineId>0022</MachineId><AccountId>1</AccountId><location_code>LOC_100</location_code><Make>Nipro</Make><Model>Model1</Model><SerialNumber>126649E</SerialNumber><IpAddress>10.10.10.10</IpAddress><Port>80</Port></Machine><Machine><MachineId>3000</MachineId><AccountId>1</AccountId><location_code>LOC_100</location_code><Make>Make3</Make><Model>Model3</Model><SerialNumber>SN3</SerialNumber><IpAddress>30.30.30.30</IpAddress><Port>80</Port></Machine></Machines></DataCaptureSettings></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>
推荐答案
CString ReplaceEntities(LPCTSTR lpszHtml)
{
CString s(lpszHtml);
s.Replace(_T(">"), _T(">"));
s.Replace(_T("<"), _T("<"));
s.Replace(_T("""), _T("\""));
s.Replace(_T("'"), _T("'"));
s.Replace(_T("&"), _T("&")); // Perform this replacement as the last one
return s;
}
这篇关于格式化后如何获取所需数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!