amp in xml getting comverted to “&”

I am creating one url and adding & to that url.


Now I am adding this url to xml .

I am creating xml via tinyxml in c++ and also tried creating same xml in php.

After creating the xml I found out that "&" is converted to "&"

Is it okay for "&" to get converted to "&"? Why is this happening ? And what could be the possible fix for this?

$strUrl ="";
$strUrl .="arg1=".$value1;
$strUrl .="&arg2=".$value2;

The output is coming as


XML has a feature called a character reference (&thingy;)

Therefore, all raw & characters must be escaped as & This is a pre-defined character reference equivalent to & (amp stands for ampersand).

Leaving an unescaped & will create invalid XML.

Note that raw < characters must also be escaped as &lt; (lt stands for less-than).

Need Your Help

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.