将Post数据添加到XML String

I collect data from a form like this :

$title = $_POST["title"];
$fname = $_POST["first_name"];
$surname = $_POST["surname"];

I want tot build an XML String and add the above post data. I have tryed the following and none of it works. It has to use "" double quotes !

$XPost = '
<MinPrice>$_POST["first_name"]</MinPrice>
';

$XPost = '
<MinPrice>"<![CDATA[$fname]]"></MinPrice>
';

Can anyone please assist. It has to use "" double quotes !

Full Example :

$strXml = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<SubmitLead xmlns="https://test.com.co.uk/webservicerequest/">
<Address1>'.{$_POST['Address1']}.'</Address1>
';

You need to add " around the value not single '.

$XPost = "<MinPrice>{$_POST['first_name']}</MinPrice>";

with dobule quote you can do this

$XPost = "<MinPrice>".$_POST["first_name"]."</MinPrice>";

Change your code like that.

$strXml = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<SubmitLead xmlns="https://test.com.co.uk/webservicerequest/">
<Address1>' . $_POST['Address1'] . '</Address1>
';

Try this code...

<?php
$simple = "<para><note>echo $_POST['first_name']</note></para>";
$p = xml_parser_create();
xml_parse_into_struct($p, $simple, $vals, $index);
xml_parser_free($p);
echo "Index array
";
print_r($index);
echo "
Vals array
";
print_r($vals);
?>

Reference xml parse