我正在尝试编写一个随机生成 xml 文件的 php。php 将生成 1-10 之间的随机数,每个数字 1-10 将在 php 中分配一个 xml 文件,该文件将在生成相应数字时出现。
到目前为止,我有:
<?php
print rand() . "<br>";
print rand(1, 10);
?>
如何将 xml 文件集成到这个 php 中?使用这个 xml 示例:
示例 1
<?xml version="3.0" encoding="utf-8" ?>
<channel>
<title>The Dog in the Park</title>
<link>http://pets.com/doginthepark/</link>
<description>
The dog in the park
<item>
<guid>1234</guid>
<title>poodle's video</title>
示例 2
<?xml version="3.0" encoding="utf-8" ?>
<channel>
<title>The Cat in the Park</title>
<link>http://pets.com/kitteninthepark/</link>
<description>
The cat in the park
<item>
<guid>1235</guid>
<title>kitten video</title>
<item>
<guid>123455</guid>
<title>tiger video</title>
因此,上面的 XML 文件具有分配的数字 1 和 2。如何将代码中的数字分配给正确的 XML,以及如何生成数字 1-10 的随机 XML 返回,它还显示 XML 文件详细信息.
任何帮助将不胜感激!抱歉,如果这个问题很明显,我是这方面的新手:)