Quantcast
Channel: Discussion Forum > Connect Data Services
Viewing all articles
Browse latest Browse all 2504

Getting elements within nodes in xml via php (2 Comments)

$
0
0

Topic by Steven Naek

Hello,

I have the following reponse in xml format:

<n0:Rows>
                     <n0:Row>Plomberie</n0:Row>
                     <n0:Row>Electricité</n0:Row>
                     <n0:Row>Chauffage / Climatisation / Ventilation</n0:Row>
                     <n0:Row>Admin</n0:Row>
                     <n0:Row>Eclairage</n0:Row>

</n0:Rows>

I used the following code:

 $matches = array();
        preg_match("/<n0:Rows>(.*)?<\/n0:Rows>/", html_entity_decode($xml), $matches);
        return $matches[1];

I was able to obtain the following:

                     <n0:Row>Plomberie</n0:Row>
                     <n0:Row>Electricité</n0:Row>
                     <n0:Row>Chauffage / Climatisation / Ventilation</n0:Row>
                     <n0:Row>Admin</n0:Row>
                     <n0:Row>Eclairage</n0:Row>

But i can not separate the elements from the nodes. I have try using DOM and SIMPLEXML. They don't work in my script. How to get the elements? Please note that the number of nodes are not definite. Thanks.

 

 

 


Viewing all articles
Browse latest Browse all 2504

Trending Articles