so i have this XML: the result of var_dump
string '
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<data>
<entry key="message Type">
<![
CDATA[
urgent
]
]></entry><entry key="message Title"><![
CDATA[
teswt
]
]></entry><entry key="message Body"><![
CDATA[
teasd
]
]></entry><entry key="message Priority"><![
CDATA[
1
]
]></entry></data>
' (length=260)
my code looks like this:
$xml = simplexml_load_string($tablerow['data']);
$inputs = $xml->xpath("/schema/user_input[@type!='hidden']/input|/schema/input");
foreach($inputs as $cur_input) {
$cur_input_name = (string)$cur_input['name'];
$cur_input_value = $task_input_values[$cur_input_name];
$input_name = isset($cur_input['label']) ? (string)$cur_input['label'] : $cur_input['name'];
}
var_dump($tablerow['data']);
$tablerow['data'] is the XML from the DB. any help how to get the message Title value from this??
Thanks!
The XPath expression you are using doesn’t even resemble the XML document you posted, so I don’t know how you would expect to ever find the values you are looking for. The following will extract “teswt” from your sample XML document:
Edit: Updated to use the SimpleXML “style” rather than XPath.