read xml using php curl

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kalla
Forum Newbie
Posts: 1
Joined: Mon Oct 24, 2011 2:01 am

read xml using php curl

Post by kalla »

hi, i have a problem with read xml using curl.

curl method:

Code: Select all

$url = "someurl";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $xml = curl_exec($ch);
    curl_close($ch);
the xml:

Code: Select all

<feed>

    <link type="TEXT">
    <categories>
    <category id="5">Apparel - Boy's</category>
    <category id="6">Apparel - Child’s</category>
    <category id="8">Apparel - Girl's</category>
    </categories>
    </link>

    <link type="TEXT">
    <categories>
    <category id="4">Apparel</category>
    <category id="2">Apparel - Men’s</category>
    <category id="1">Apparel - Woman’s</category>
    </categories>
    </link>
        
    </feed>
how do i get all the category values and its "id" for all <link>

e.g. -
5 - Apparel - Boy's
6 - Apparel - Child's
8 - Apparel - Girl's

4 - Apparel
2 - Apparel - Men’s
1 - Apparel - Woman’s

please help..
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: read xml using php curl

Post by Celauran »

Post Reply