Please tell me how can i get $String value for key field name="Contact Tags (Raw)" Basically i need something like this:
$XML->result->contact->Group_Tag("Sequences and Tags")->field("Contact Tags (Raw)")
This is result I got
MY PHP CODE:
<?php
$data = <<<STRING
<search>
<equation>
<field>E-Mail</field>
<op>e</op>
<value>anast@gmail.com</value>
</equation>
</search>
STRING;
$data = urlencode(urlencode($data));
$appid = "xxxxxxxxxxxxxxxxxx";
$key = "xxxxxxxxxxxxxxxxxx";
$reqType = "search";
$postargs = "appid=".$appid."&key=".$key."&reqType=".$reqType."&data=".$data;
$request = "https://api.moon-ray.com/cdata.php";
$session = curl_init($request);
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);
curl_setopt ($session, CURLOPT_HEADER, false);
curl_setopt ($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
header("Content-Type: text/xml");
$decoded = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $response);
echo $decoded;
You can try this
$string = '<result>
<contact id="90676">
<Group_Tag name="Sequences and Tags">
<field name="Contact Tags (Raw)">
test test
</field>
</Group_Tag>
</contact>
</result>';
$xml = simplexml_load_string($string);
if($xml->contact->Group_Tag['name'] == 'Sequences and Tags'){
if($xml->contact->Group_Tag->field['name'] == 'Contact Tags (Raw)'){
echo $xml->contact->Group_Tag->field;
}
}
Updated
<?php
$xml=simplexml_load_file("http://i.shn-host.ru/json/srch.php") or die("Error: Cannot create object");
foreach ($xml->contact->Group_Tag as $Group_Tag) {
if($Group_Tag['name'] == 'Sequences and Tags'){
foreach ($Group_Tag as $field) {
if($field['name'] == 'Contact Tags (Raw)'){
echo $field;
}
}
}
}
?>
Result I got
22*/96/72/77/78/79/82/105/121/136/146/209/246/259/260/262/264/281/*282