Home >Backend Development >PHP Tutorial >How to output xml attributes in php_PHP tutorial

How to output xml attributes in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:02:16817browse

How PHP outputs XML attributes

This article mainly introduces the method of PHP outputting XML attributes. It analyzes the usage skills of PHP's method of operating XML file attributes with an example, which has certain reference. For reference value, friends in need can refer to it

The example in this article describes how php outputs xml attributes. Share it with everyone for your reference. The specific analysis is as follows:

This code demonstrates through a simple example how PHP reads an xml file and outputs xml attributes

?

1

2

3

4

5

6

$xml = simplexml_load_file("books.xml");

foreach($xml->book[0]->author->attributes() AS $a => $b) {

echo "$a = $b
";

}

?>

1 2

3

4

5

6

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

A

B

C

C

D

E

F

G

H

$xml = simplexml_load_file("books.xml");

foreach($xml->book[0]->author->attributes() AS $a => $b) { echo "$a = $b
";

}?>
The content of the xml file is as follows
?
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
A B C C D E F G H
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/970760.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/970760.htmlTechArticleHow to output xml attributes in php. This article mainly introduces the method of outputting xml attributes in php and analyzes the php operation with examples. The usage skills of XML file attributes method have certain reference value and need to be...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn