Reputation: 11
I have a requirement to load the variable from txt file to the particular XML element. but some how I am not able to echoing properly.
Here is my output of txt file (userlist.txt) abc xyz LMN
and below is code .
<?php
foreach(file('userlist.txt') as $line) {
$xml_post_string = '<?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/">
<soap:Body>
<Getid xmlns="http://test_xyz/">
<uname>'. $line. '</uname>
<org>Test_GRP</org>
</Getid>
</soap:Body>
</soap:Envelope>';
echo $xml_post_string;
}
?>
and below is OUTPUT
<?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/">
<soap:Body>
<Getid xmlns="http://test_xyz/">
<uname>abc
</uname>
<org>Test_GRP</org>
</Getid>
</soap:Body>
</soap:Envelope>
the uname element is not inline, any idea how I do that.
Upvotes: 0
Views: 41