[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    [Boost-users] boost ptree XML parsing for special character
From:       Uthpal Urubail <uthpal.urubail () altair ! com>
Date:       2015-07-29 8:58:59
Message-ID: D4AD437F20F5ED4989555AA4387B86C4AFE25982 () Blrexch10a ! indiablr ! altair ! com
[Download RAW message or body]

Experts,
I am looking for the help in parsing special characters in XML using boost.
Original Text: <module>'Admin'</module>
Exported Text: <module>&apos;Admin&apos;</module>

Using the below code:
ptree xmlTree;
read_xml("org.txt",xmlTree,boost::property_tree::xml_parser::trim_whitespac=
e);
std::string filePath("outFile.txt");
xml_writer_settings<char> settings(' ', 4);
boost::property_tree::write_xml(filePath, xmlTree, std::locale(),settings);

Any help is highly appreciated
Regards,
UJ





[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">Experts,<o:p></o:p></span></p> <p \
class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">I am looking for the help in parsing \
special characters in XML using boost.<o:p></o:p></span></p> <p class="MsoNormal" \
style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">Original Text: \
</span>&lt;module&gt;<b>'Admin'</b>&lt;/module&gt;<span \
style="font-size:9.5pt;font-family:Consolas"> <o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">Exported Text:</span> \
&lt;module&gt;<b>&amp;apos</b>;Admin<b>&amp;apos</b>;&lt;/module&gt;<o:p></o:p></p> \
<p class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas"><o:p>&nbsp;</o:p></span></p> <p \
class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">Using the below \
code:<o:p></o:p></span></p> <p class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">ptree xmlTree;<o:p></o:p></span></p> <p \
class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">read_xml(<span \
style="color:#A31515">&quot;org.txt&quot;</span>,xmlTree,boost::property_tree::xml_parser::trim_whitespace);<o:p></o:p></span></p>
 <p class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">std::string filePath(<span \
style="color:#A31515">&quot;outFile.txt&quot;</span>);<o:p></o:p></span></p> <p \
class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">xml_writer_settings&lt;char&gt; \
settings(<span style="color:#A31515">' '</span>, 4);<o:p></o:p></span></p> <p \
class="MsoNormal" style="text-autospace:none"><span \
style="font-size:9.5pt;font-family:Consolas">boost::property_tree::write_xml(filePath, \
xmlTree, std::locale(),settings);<o:p></o:p></span></p> <p \
class="MsoNormal"><o:p>&nbsp;</o:p></p> <p class="MsoNormal">Any help is highly \
appreciated<o:p></o:p></p> <p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">UJ<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<o:p></o:p></p> </div>
</body>
</html>



_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
--===============3187313566645991037==--

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic