我正在尝试使用jquery解析xml。 我的项目的目的是通过获取标签来动态创建按钮。 例如:如果我有两个Scenario标签,我需要在运行时创建2个按钮。
问题是我不知道如何从其网址中检索图像并将其存储在文件夹中。
此外,如果有一种方法可以在本地存储xml,因为我有链接到xml,所以即使我没有互联网连接,我的应用程序也可以获取本地可用的数据
P.S。我正在使用html和jquery。
我的XML如下:
<root>
<home src="images/pic1.jpg"/>
<Scenario value="Supply Chain Management">
<Scene value="Supply Chain Info Center">
<valProps src="http://10.52.49.152:8080/visiondemo/sample.jpg">Supply Chain Info Center Content1</valProps>
<valProps src="http://10.52.49.152:8080/visiondemo/sample.jpg">SPIC - Content2</valProps>
<valProps src="http://10.52.49.152:8080/visiondemo/sample.jpg">SPIC - COntent3</valProps>
</Scene>
<Scene value="SCPM">
<valProps src="http://10.52.49.152:8080/visiondemo/sample.jpg">SCPM_Content1</valProps>
<valProps src="http://10.52.49.152:8080/visiondemo/sample.jpg">SCPM_Content2</valProps>
</Scene>
</Scenario>
<Scenario value="Supply Chain Management2">
<Scene value = "Supply Chain"></Scene>
</Scenario>
</root>
答案 0 :(得分:0)
使用file_get_content
和file_put_content
php函数。
<?php
$file = 'url_image_file';
// Open the file to get existing content
$current = file_get_contents($file);
// Append image to the file
$current .= "new_file_name";
// Write the contents back to the file
file_put_contents($file, $current);
?>