I have a directory called incoming_folder in which there are some xml files (36017P.xml, 36031P.xml, and hello.xml) in it.
<?php
$src_dir = 'incoming_folder'; /* Place where xml files are present */
$xml_files = preg_grep('~\.(xml)$~', scandir($src_dir));
print_r($xml_files); /* Line#A */
Line#A display the following o/p:
Array ( [3] => 36017P.xml [5] => 36031P.xml [7] => hello.xml )
$xml=simplexml_load_file("incoming_folder") or die('Unable to load XML');
$path_program_en = $xml->xpath('//StringAssetInfo/attrName[text()="CASE_SERIES_TITLE"]/..');
$path_title_en = $xml->xpath('//StringAssetInfo/attrName[text()="CASE_EPISODE_TITLE"]/..');
$path_description_en = $xml->xpath('//TextAssetInfo/attrName[text()="CASE_DESCRIPTION_ENGLISH"]/..');
?>
Problem Statement:
I am wondering what changes I should make in the php code above so that it pull the sub-elements CASE_SERIES_TITLE, CASE_EPISODE_TITLE, and CASE_DESCRIPTION_ENGLISH values from their respective xmls 36017P.xml, 36031P.xml, and hello.xml and parse it in the table rows.
Program (EN) Title (EN) Description (EN)
CASE_SERIES_TITLE, CASE_EPISODE_TITLE, and CASE_DESCRIPTION_ENGLISH sub-elements are present in every xml (36017P.xml, 36031P.xml, and hello.xml)
<tr>
<th style="width:8%;" >Program (EN)</th>
<th style="width:8%;" >Title (EN)</th>
<th style="width:8%;" >Description (EN)</th>
</tr>
<td style="width:8%; text-align:center;"><?php echo $path_program_en; ?></td>
<td style="width:8%; text-align:center;"><?php echo $path_title_en; ?></td>
<td style="width:8%; text-align:center;"><?php echo $path_description_en; ?></td>
</tr>
The snippet of content from 36017P.xml is:
<StringAssetInfo>
<attrName>CASE_SERIES_TITLE</attrName>
<attrTagName>CASE_SERIES_TITLE</attrTagName>
<value>PrimeTime Politics</value>
</StringAssetInfo>
<attrName>CASE_SERIES_TITLE</attrName>,<attrTagName>CASE_SERIES_TITLE</attrTagName>and<value>PrimeTime Politics</value>. It is unique in the whole xml.