문제

I've searched pretty extensively, forgive me if this happens to be a repeat question.

I'm trying to retrieve first and last names with the Google Contacts api. Gathering emails was easy enough with:

$result = $xml->xpath('//gd:email');
$count = 0;
foreach ($result as $title) {
    $count++;
    $email = $title->attributes()->address;
}

I'm having absolutely no luck figuring out how to use

//gd:fullName

All help is appreciated.

도움이 되었습니까?

해결책

The full name is not stored in an attribute, but as text value – that makes things even simpler for parsing.

$names = $xml->xpath('//gd:fullName');
foreach ($names as $name) {
    echo $name;
}

Whenever a SimpleXML node is casted to string, it returns its text value (here, the full name).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top