Skip to content
Advertisement

Parse XML tag into array not depend on XML structure [closed]

Which is the quickest way in PHP to parse “category_fullname” texsts into array not depend on XML structure ?

JavaScript

Array should looks like :

Heureka.sk | Auto-moto | Pneumatiky

Heureka.sk | Auto-moto | Strešné boxy

Heureka.sk | Auto-moto | Strešné nosiče | Nosiče lyží

Advertisement

Answer

The quickest way is to use simpleXML, array_map and xpath.

JavaScript

$xml->xpath returns an array of simple XML elements. ‘//CATEGORY_FULLNAME’ searches for the tag anywhere in the XML. With array_map the function strval is applied to all elements to get the values.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement