2016-08-09 4 views
1

PHP에서 simplexmlelement 함수를 사용하는 방법을 배우고 있으며 지금까지 모든 것이 잘 진행 중입니다. 구문 오류 : 나는simplexml로 xml 피드 가져 오기

[paragraphs] => SimpleXMLElement Object ([paragraph] => Array ([0] => SimpleXMLElement Object ([@attributes] => Array ([id] => 1 [type] => 0) [name] => Ground Floor - Private Entrance Hall [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => 3.94m max x 2.44m max (inc stairs) [imperial] => 12'11 max x 8'0 max (inc stairs) [mixed] => 3.94m max x 2.44m max (inc stairs) (12'11 max x 8') [text] => Private entrance with composite entrance door opening into the ground floor section of the property. The entrance hall has a radiator and doors off to both a ground floor w.c. and Bedroom 2. Stairs also rise from the entrance hall to the first floor.) [1] => SimpleXMLElement Object ([@attributes] => Array ([id] => 2 [type] => 0) [name] => Ground Floor WC [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => 1.45m x 1.17m [imperial] => 4'9 x 3'10 [mixed] => 1.45m x 1.17m (4'9 x 3'10)) [text] => Serving the adjacent ground floor bedroom with close coupled w.c. and) [2] => SimpleXMLElement Object ([@attributes] => Array ([id] => 3 [type] => 0) [name] => Bedroom 2 [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => 2.44m x 2.11m [imperial] => 8'0 x 6'11 [mixed] => 2.44m x 2.11m (8'0 x 6'11)) [text] => With double glazed window to rear. Radiator.) [3] => SimpleXMLElement Object ([@attributes] => Array ([id] => 4 [type] => 0) [name] => SimpleXMLElement Object () [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => SimpleXMLElement Object () [imperial] => SimpleXMLElement Object () [mixed] => SimpleXMLElement Object ()) [text] => Returning to the hallway stairs rise to the first floor landing.) [4] => SimpleXMLElement Object ([@attributes] => Array ([id] => 5 [type] => 0) [name] => First Floor - Landing [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => SimpleXMLElement Object () [imperial] => SimpleXMLElement Object () [mixed] => SimpleXMLElement Object ()) [text] => with doors off to the following first floor accommodation) [5] => SimpleXMLElement Object ([@attributes] => Array ([id] => 6 [type] => 0) [name] => Bedroom 1 [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => 2.67m x 2.49m (plus built in wardrobes) [imperial] => 8'9 x 8'2 (plus built in wardrobes) [mixed] => 2.67m x 2.49m (plus built in wardrobes) (8'9 x 8'2) [text] => A well proportioned double bedroom with sliding doors to two sets of built in wardrobes. Double glazed window to rear. Radiator.) [6] => SimpleXMLElement Object ([@attributes] => Array ([id] => 7 [type] => 0) [name] => Bathroom [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => 2.11m x 1.68m [imperial] => 6'11 x 5'6 [mixed] => 2.11m x 1.68m (6'11 x 5'6)) [text] => Fitted with a three piece suite comprising bath with shower over and screen to side. Pedestal wash hand basin and close coupled w.c. Radiator. Obscured glazed, double glazed window. Part tiling to walls. Extractor fan. Spot lights inset to ceiling.) [7] => SimpleXMLElement Object ([@attributes] => Array ([id] => 8 [type] => 0) [name] => Sitting/Dining Room [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => 6.05m x 3.07m [imperial] => 19'10 x 10'1 [mixed] => 6.05m x 3.07m (19'10 x 10'1)) [text] => An excellent dual purpose reception room of surprising proportions with ample space for both seating and dining in comfort. The room has good natural light entering the room through PVCu double glazed double doors to a "Juliette" balcony and also through a double glazed window to the rear. TV aerial point. Two radiators. Arch through to the kitchen.) [8] => SimpleXMLElement Object ([@attributes] => Array ([id] => 9 [type] => 0) [name] => Kitchen [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => 2.34m x 2.21m [imperial] => 7'8 x 7'3 [mixed] => 2.34m x 2.21m (7'8 x 7'3)) [text] => Fitted with a range of both base and eye level storage units as well as built in appliances. The base level units being surmounted by rolled edge work surfaces. Complementary splash back tiling. Inset stainless steel sink unit with mixer tap. Built in oven above which is a four ring gas hob with fitted extractor hood over. Wall mounted gas boiler. Space for white goods, plumbing for automatic washing machine.) [9] => SimpleXMLElement Object ([@attributes] => Array ([id] => 10 [type] => 0) [name] => Outside [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => SimpleXMLElement Object () [imperial] => SimpleXMLElement Object () [mixed] => SimpleXMLElement Object ()) [text] => To the front of the property there is a designated car parking space.) [10] => SimpleXMLElement Object ([@attributes] => Array ([id] => 11 [type] => 0) [name] => Further Information [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => SimpleXMLElement Object () [imperial] => SimpleXMLElement Object () [mixed] => SimpleXMLElement Object ()) [text] => Any fixtures and fittings not mentioned in these details are excluded from the sale price. No services or appliances which may have been included in these details have been tested and therefore cannot be guaranteed to be in good working order. Nothing therein shall be a warranty or condition and neither the Vendor nor ourselves will be liable to the Purchaser in respect of any mis-statement or misrepresentation made at or before the date hereof by the Vendor, his servants or agents or otherwise. COUNCIL TAX BAND (A) : EPC RATING C (75): SERVICES: All mains services are connected to the property. VIEWING:By telephone appointment with ) [11] => SimpleXMLElement Object ([@attributes] => Array ([id] => 12 [type] => 0) [name] => Personal Interest [file] => SimpleXMLElement Object () [dimensions] => SimpleXMLElement Object ([metric] => SimpleXMLElement Object () [imperial] => SimpleXMLElement Object () [mixed] => SimpleXMLElement Object ()) [text] => We are obliged to inform you that this property is owned by a director/senior partner of.))) 

변수의 값을 얻을 그래서 시도 다른 방법은 XML의 한 부분에서 공급 부분에서 모든 콘텐츠를 관리해야하지만 오류가 점점 오전 : 구문 분석 오류를 예상치 못한 '0'(T_LNUMBER), 식별자 (T_STRING) 또는 가변 (T_VARIABLE) 또는 기대 '{'또는 '$'

피곤이 다음 난 그냥 foreach 루프를 시도

$feed = file_get_contents('http://mysite.co.uk/inc/feed.xml'); 
$xml = simplexml_load_string($feed); 
echo 'Desc: ' . $xml->paragraphys->paragraph->0->id; 
echo 'Desc: ' . $xml->paragraphys->paragraph->$0->id; 

하지만, 그 중 하나가 작동하지 않습니다

foreach($xml->paragraphys->paragraph as $p) { 
$paragraph = new Paragraph; 
echo '<br/>Par: ' . $p->id; 
} 

어떤 도움을 아주 많이 그것에 대해

답변

1
<?php 
echo 'Desc:'.(string)$xml->paragraphs->paragraph[0]->id; 
?> 
+0

감사 건배 슈카을 감상 할 수있다, 난 그냥 그것을 시도했지만 그 값을 다시 가져 오지 않습니다. – shuka

+0

소스 xml과 몇 가지 코드의 스 니펫을 게시 할 수 있습니까? – simialbi

+0

ok 피드를 가져 오는 방법을 보여주는 코드를 업데이트했습니다. 익지 않는 먹이를 넣어 두었습니다 – shuka