Hướng dẫn xml elements in php - các phần tử xml trong php

Nhiều ví dụ trong tài liệu tham khảo này yêu cầu một chuỗi XML. Thay vì lặp lại chuỗi này trong mỗi ví dụ, chúng tôi đặt nó vào một tệp mà chúng tôi đưa vào mỗi ví dụ. Tệp bao gồm này được hiển thị trong phần ví dụ sau. Ngoài ra, bạn có thể tạo một tài liệu XML và đọc nó bằng SimplexML_Load_File [].simplexml_load_file[].

Ví dụ #1 bao gồm tệp ví dụ.php với chuỗi XML



 
  PHP: Behind the Parser
  
   
    Ms. Coder
    Onlivia Actora
   
   
    Mr. Coder
    El ActÓr
   
  
  
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  
  
   PHP solves all my web problems
  
  7
  5
 

XML;
?>

Tính đơn giản của SimplexML xuất hiện rõ ràng nhất khi một người trích xuất một chuỗi hoặc số từ tài liệu XML cơ bản.

Ví dụ #2 Nhận



 
  PHP: Behind the Parser
  
   
    Ms. Coder
    Onlivia Actora
   
   
    Mr. Coder
    El ActÓr
   
  
  
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  
  
   PHP solves all my web problems
  
  7
  5
 

XML;
?>
0



 
  PHP: Behind the Parser
  
   
    Ms. Coder
    Onlivia Actora
   
   
    Mr. Coder
    El ActÓr
   
  
  
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  
  
   PHP solves all my web problems
  
  7
  5
 

XML;
?>
1



 
  PHP: Behind the Parser
  
   
    Ms. Coder
    Onlivia Actora
   
   
    Mr. Coder
    El ActÓr
   
  
  
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  
  
   PHP solves all my web problems
  
  7
  5
 

XML;
?>
2

Ms. Coder played by Onlivia Actora
Mr. Coder played by El ActÓr
2

Ví dụ #6 so sánh các yếu tố và thuộc tính với văn bản

Để so sánh một phần tử hoặc thuộc tính với một chuỗi hoặc chuyển nó vào một hàm yêu cầu một chuỗi, bạn phải chuyển nó vào một chuỗi bằng cách sử dụng

PHP solves all my web problems
9. Nếu không, PHP coi phần tử là một đối tượng.



 
  PHP: Behind the Parser
  
   
    Ms. Coder
    Onlivia Actora
   
   
    Mr. Coder
    El ActÓr
   
  
  
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  
  
   PHP solves all my web problems
  
  7
  5
 

XML;
?>
4



 
  PHP: Behind the Parser
  
   
    Ms. Coder
    Onlivia Actora
   
   
    Mr. Coder
    El ActÓr
   
  
  
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  
  
   PHP solves all my web problems
  
  7
  5
 

XML;
?>
5



 
  PHP: Behind the Parser
  
   
    Ms. Coder
    Onlivia Actora
   
   
    Mr. Coder
    El ActÓr
   
  
  
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  
  
   PHP solves all my web problems
  
  7
  5
 

XML;
?>
6



 
  PHP: Behind the Parser
  
   
    Ms. Coder
    Onlivia Actora
   
   
    Mr. Coder
    El ActÓr
   
  
  
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  
  
   PHP solves all my web problems
  
  7
  5
 

XML;
?>
7

Ms. Coder played by Onlivia Actora
Mr. Coder played by El ActÓr
2

Ví dụ #7 so sánh hai yếu tố

Cho đến nay, chúng tôi chỉ đề cập đến công việc đọc tên phần tử và giá trị của chúng. SimplexML cũng có thể truy cập các thuộc tính phần tử. Các thuộc tính truy cập của một phần tử giống như các phần tử của một mảng.



 
  PHP: Behind the Parser
  
   
    Ms. Coder
    Onlivia Actora
   
   
    Mr. Coder
    El ActÓr
   
  
  
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  
  
   PHP solves all my web problems
  
  7
  5
 

XML;
?>
9

0

Ms. Coder played by Onlivia Actora
Mr. Coder played by El ActÓr
2

Ví dụ #6 so sánh các yếu tố và thuộc tính với văn bản

Để so sánh một phần tử hoặc thuộc tính với một chuỗi hoặc chuyển nó vào một hàm yêu cầu một chuỗi, bạn phải chuyển nó vào một chuỗi bằng cách sử dụng

PHP solves all my web problems
9. Nếu không, PHP coi phần tử là một đối tượng.

2

3

4

5

Bài Viết Liên Quan

Chủ Đề