我需要将变量从txt文件加载到特定的XML元素。但是有些我无法正确地回声。
这是我的txt文件(userlist.txt)的输出 abc y LMN
和下面是代码。
<?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;
}
?>
下面是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>
uname元素不是内联的,我不知道该怎么做。