I have a XML and want to read values from only specific child nodes. Then I want to put those read values into an array and return this array at the end. So I want to get all values of name saved in an array and return this array. In the end, I want to display all values of this array beneath each other in an HTML file.
Here is my idea so far (which does not work obviously):
$items= simplexml_load_file('https://example.com/xml');
$itemList = array();
foreach ($items as $item->name) {
// Push the values of name of the item nodes into an array
}
return $itemList;
Here is the structure of the XML file:
<item>
<name>Name 1</name>
</item>
<item>
<name>Name 2</name>
</item>
<item>
<name>Name 3</name>
</item>
<item>
<name>Name 4</name>
</item>
echo impode("<br>", $names);then. This is super basic programming.