I'm collecting form information and I have to post that data to a URL in XML format. So I'm putting the XML into a post string and using cURL to execute the post. How would I echo the proper form fields into the XML? In the ProjectId I put what I thought would be the code, but Notepad++ isn't showing it as being valid PHP so I think that's wrong. Thanks!
$post_string = '
<?xml version="1.0" encoding="UTF-8" ?>
<Ping vid="" sid="">
<ProjectInfo>
<ProjectId><? echo $projectid; ?></ProjectId>
<SubProject></SubProject>
</ProjectInfo>
</Ping>
';
I was using this link to figure it out: http://www.codediesel.com/php/posting-xml-from-php/
Just concatenate the string
$post_string = '
<?xml version="1.0" encoding="UTF-8" ?>
<Ping vid="" sid="">
<ProjectInfo>
<ProjectId>' . $projectid . '</ProjectId>
<SubProject></SubProject>
</ProjectInfo>
</Ping>
';
Just another style of usage. Try this style for giving a well formatted xml string to a php variable.
$post_string =<<<XML
<Ping vid="" sid="">
<ProjectInfo>
<ProjectId>$projectid</ProjectId>
<SubProject></SubProject>
</ProjectInfo>
</Ping>
XML;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With