特定の CollageObjectInfo 要素から PositionX 属性の値が必要で、選択する要素の番号を含む変数があります。
私が達成したいのは次のようなものです(当然、このコードは機能しません):
$xml = simplexml_load_file("vars.xml");
$number = 140;
$positionx = $xml->CollageObjects->CollageObjectInfo[$number]->attributes()->PositionX;
参照元:
<?xml version="1.0" encoding="utf-8"?>
<CollageInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" BgType="image" BgImagePath="http://localhost:8080/images/dreamboard/backgrounds/pattern2.jpg" BgColor="0" CanvasWidth="960" CanvasHeight="730" AutoSaveTime="50000" SelectedMemberDreamId="00000000-0000-0000-0000-000000000000">
<CollageObjects>
<CollageObjectInfo xsi:type="CollageImageInfo"
MemberDreamId="a5d55cc1-8eb2-4e28-9ad9-4b9ea250926d"
PositionX="670" PositionY="50" Rotation="0"
ScaleX="0.5" ScaleY="0.5" Alpha="1" DropShadow="true"
Coords="670,77,887.5,77,887.5,337,670,337"
Type="image"
DreamboardImageId="00000000-0000-0000-0000-000000000000"
ImagePath="http://cubicflow.com/dan/dia/images/dream-1.jpg"
Caption="I am flying without taking my shoes off." />
<CollageObjectInfo xsi:type="CollageImageInfo"
MemberDreamId="2f7a6c1b-6006-4a5d-b9d8-b653ee7ea4ca" PositionX="82" PositionY="323" Rotation="-40" ScaleX="0.5" ScaleY="0.5" Alpha="1" DropShadow="true" Coords="2,400,219.5,400,219.5,710,2,710" Type="image" DreamboardImageId="00000000-0000-0000-0000-000000000000" ImagePath="http://cubicflow.com/dan/dia/images/dream-2.jpg" Caption="I am continuing to improve physical conditioning." />
<CollageObjectInfo xsi:type="CollageImageInfo"
MemberDreamId="7230bb7a-58a6-49d3-bfc7-ed7e4486da85" PositionX="150" PositionY="404" Rotation="0" ScaleX="0.46" ScaleY="0.44" Alpha="1" DropShadow="true" Coords="680.75,381.25,880.85,381.25,880.85,736.75,680.75,736.75" Type="text" DreamboardImageId="00000000-0000-0000-0000-000000000000" ImagePath="" Caption="Lorem ipsum dolor yeeeeeeeahhhhssssss sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." />
</CollageObjects>
</CollageInfo>