This is my XML with name test.xml:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:test="http://www.test.com/rss/2.0">
<positionfeed>
<test:import user="accounts@test.com" site="www.test.com" />
<job>
<id>83762455</id>
<employer>Mount Ida College</employer>
<title>Assistant Professor, Dental Hygiene</title>
<description>As a faculty member, you will provide instruction in didactic courses, clinics, and/or labs in the Dental Hygiene Program.</description>
<postingdate>2016-10-21</postingdate>
<joburl>http://url.com</joburl>
<location>Newton, MA</location>
<category>Education</category>
</job>
<job>
<id>83762405</id>
<employer>Veterinary Orthopedic & Sports Medicine Group</employer>
<title>Overnight Recovery Technician</title>
<description>As a faculty member, you will provide instruction in didactic courses, clinics, and/or labs in the Dental Hygiene Program.</description>
<postingdate>2016-10-25</postingdate>
<joburl>http://url.com</joburl>
<location>Annapolis Junction, MD</location>
<category>Installer/Technician</category>
</job>
</positionfeed>
</rss>
This is my PHP page where I'm parsing it:
<?php
$languages = simplexml_load_file("test.xml");
print_r($languages);
foreach ($languages->job as $job) {
echo $job->title;
echo "<br>";
}
?>
I want:
job->id
job->title
and so on
=============================
print_r($languages) gives:
SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [positionfeed] => SimpleXMLElement Object ( [job] => Array ( [0] => SimpleXMLElement Object ( [id] => 83762455 [employer] => Mount Ida College [title] => Assistant Professor, Dental Hygiene [description] => As a faculty member, you will provide instruction in didactic courses, clinics, and/or labs in the Dental Hygiene Program. [postingdate] => 2016-10-21 [joburl] => http://url.com [location] => Newton, MA [category] => Education ) [1] => SimpleXMLElement Object ( [id] => 83762405 [employer] => Veterinary Orthopedic & Sports Medicine Group [title] => Overnight Recovery Technician [description] => As a faculty member, you will provide instruction in didactic courses, clinics, and/or labs in the Dental Hygiene Program. [postingdate] => 2016-10-25 [joburl] => http://url.com [location] => Annapolis Junction, MD [category] => Installer/Technician ) ) ) )
============================
I tried researching a lot.
If I remove below three lines manually the PHP code works fine and displays values as needed, but I am unable to remove them dynamically.
<rss version="2.0" xmlns:test="http://www.test.com/rss/2.0">
<test:import user="accounts@test.com" site="www.test.com" />
</rss>
So either of the way will work, if anyone can help, either help me to remove these three lines dynamically on load on PHP page else able to get values of the required nodes.
Again as description is long, I want:
job->id
job->title
and so on