이것은 속임수 질문이 아닙니다. 다른 것들은 print_r에 속성이 없습니다. 그러나 xlink : href 속성에 액세스 할 수 없습니다.PHP SimpleXML에 속성이 없습니다.
여기에 내가 무엇을 시도했다입니다 :
$xml = simplexml_load_string($imageSVG);
$image = $xml->g->image; // works
$style = $xml->g->image->style; // works
$style = $xml->g->image['style']; // works
$remoteHref = $xml->g->image['xlink:href']; // doesn't work
$remoteHref = $xml->g->image['href']; // doesn't work
$remoteHref = $xml->g->image->href; // doesn't work
$array= $xml->g->image->attributes('xlink'); // 0 elements in the array
가 여기에 입력 된 XML의 :
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="351" height="351" xml:space="preserve"><desc></desc><defs></defs><g transform="translate(145 175) scale(0.4 0.4)"><image xlink:href="http://cdn.katori.com/BfFEEXuBTrii818CNQvN_71344PL.jpg" style="stroke: none; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); opacity: 1;" transform="translate(-300 -300)" width="600" height="600" preserveAspectRatio="none"></image></g></svg>
감사합니다! 의 - 태그
당신이 구문 분석 할 XML의 형식을 알고 있다면 당신은 항상 당신이 할 수있는 빠른 더러운 해킹에 대한 필요 : - 매트
이것은 속는 사람이 아닙니다. [그 (것)들의 살벌한 수백이있다] (http://stackoverflow.com/search?q=%5Bphp%5D+simplexml+namespace) : P (그러나 당신이 당신의 수색에 '네임 스페이스'를 추가하는 것을 모른다면 조금 힘들 수 있습니다). – Wrikken
가능한 [Simplexml 네임 스페이스가있는 특성 얻기] (http://stackoverflow.com/questions/13511217/simplexml-get-attributes-with-a-namespace) – Wrikken