From gateway I get one very unsual result it’s HTML inside XML, which confuses me. When I echo variable $result this is the output:
<Results>
<XML_Report>
<Subject>
<EFX_Code>199</EFX_Code>
<Referral>SPECIAL_WOHA</Referral>
</Subject>
</XML_Report>
<HTML_Report>
<![CDATA[
<html>
<head>
</head>
<body>
<a name="mergereport" />
<p>MERGE REPORT</p>
<table border="1" WIDTH="100%" cellpadding=0 cellspacing=0>
<tr><td class=heading colspan=4 align="center" bgcolor="#c0c0c0"><p class=heading>Personal Information Since 08/09/09 FAD 04/17/12</p></td></tr>
<tr><td><br /></td><td><br /></td><td width="15%" align=center><p><b>Reported</b></p></td><td align=center><p><b>Bur</b></p></td></tr>
<tr>
<td width="15%" valign=top align=right><p class=pipad><b>
Name<br />
SSN<br />
Inquiry SSN<br />
DOB<br />
Address
</b></p></td>
</tr></table>
</body>
</html>
]]>
</HTML_Report>
</Results>
How can I parse that variable to extract out only part of HTML I want eg. anything withing tags inside with PHP… I’ve browsed a lot but can’t find any proper answer if such parsing is possible and more important HOW?
A quick and dirty solution:
Summary: split the xml string at the HTML_Report start and end tags, each time keeping only the element of the resulting array containing the HTML portion. This will result in $html_portion also containing the CDATA wrapper so if you want to avoid that then split on “”.
It ain’t elegant but it gets the job done.
EDIT: Fixed code from $xml[1] to $arr[1] – thanks Marc B.