質問編集履歴

2

取得するXML、取得するPHPコードの詳細追加

2021/08/02 12:35

投稿

tr1991
tr1991

スコア6

test CHANGED
File without changes
test CHANGED
@@ -32,21 +32,37 @@
32
32
 
33
33
  ```XML
34
34
 
35
- <title>Test</title>
35
+ <feed xmlns="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
36
36
 
37
- <content:encoded>
37
+ <entry>
38
38
 
39
- <img src="https://hoge.jpg"/>
39
+ <title>Test</title>
40
40
 
41
+ <content:encoded>
42
+
43
+ <img src="https://hoge.jpg"/>
44
+
41
- </content:encoded>
45
+ </content:encoded>
46
+
47
+ </entry>
48
+
49
+ </feed>
42
50
 
43
51
  ```
44
52
 
45
53
  ```PHP
46
54
 
47
- $title = (string)$item->title;
55
+ $rss_data = @simplexml_load_string($xml,'SimpleXMLElement', LIBXML_NOCDATA);
48
56
 
57
+
58
+
59
+ foreach($rss_data->entry as $item) {
60
+
61
+ $title = (string)$item->title;
62
+
49
- $image = (string)$item->children("http://purl.org/rss/1.0/modules/content/")->encoded;
63
+ $image = (string)$item->children("http://purl.org/rss/1.0/modules/content/")->encoded;
64
+
65
+ }
50
66
 
51
67
 
52
68
 

1

詳細の追加

2021/08/02 12:35

投稿

tr1991
tr1991

スコア6

test CHANGED
File without changes
test CHANGED
@@ -17,6 +17,8 @@
17
17
 
18
18
 
19
19
  ```PHP
20
+
21
+ string(4) "Test"
20
22
 
21
23
  string(2) " "
22
24
 
@@ -46,6 +48,12 @@
46
48
 
47
49
  $image = (string)$item->children("http://purl.org/rss/1.0/modules/content/")->encoded;
48
50
 
51
+
52
+
53
+ var_dump($title);
54
+
55
+ var_dump($image);
56
+
49
57
  ```
50
58
 
51
59