开发者

displaying xml file content within php

开发者 https://www.devze.com 2023-03-04 22:00 出处:网络
i have xml file( product.xml) and i need to display the whole content( including xml declaration , tags and node values) of this file within php program. how can i achieve that?

i have xml file( product.xml) and i need to display the whole content( including xml declaration , tags and node values) of this file within php program. how can i achieve that?

products.xml

<?xml version="1.0" encoding="utf-8"?>
<products>
<product onshelf="yes">          
<type>cosmetic</type>          
<address>   
<suburb>Melbourne</suburb> 
</address>      
</product>  
<product onshelf="yes">          
<开发者_如何学Gotype>cosmetic</type>          
<address>   
<suburb>Melbourne</suburb> 
</address>      
</product>  
</products> 

output:

<?xml version="1.0" encoding="utf-8"?>
<products>
<product onshelf="yes">          
<type>cosmetic</type>          
<address>   
<suburb>Melbourne</suburb> 
</address>      
</product>  
<product onshelf="yes">          
<type>cosmetic</type>          
<address>   
<suburb>Melbourne</suburb> 
</address>      
</product>  
</products> 


<?php echo htmlspecialchars(file_get_contents('product.xml')); ?>

The question is a bit misleading. Properly formalized: How can I display the raw XML in a browser using PHP.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号