I want to fetch value of msg element using regular expression. Please help
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:iana:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iana:xml:ns:epp-1.0 epp-1.0.xsd">
<result code="2400">
<msg>Command fail</msg>
<value>mjdizyn.com</value>
</result>
<unspec/>
</epp>
I am using this code:
PHP Code:
function startElement($parser, $name, $attrs)
{
if($name == "MSG")
{
global $a;
$a = 0;
}
}
function endElement($parser, $name)
{
}
function characterData($parser, $name)
{
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
//$fp = fopen($file, "r");
$data = $file; //fread($fp, 4096);
xml_parse($xml_parser, $data);
xml_parser_free($xml_parser);
Bookmarks