通过ajax将参数转换为get/post方法的phpxml

transfer parameter via ajax to php xml by get/post method

本文关键字:post 方法 phpxml get ajax 参数 转换 通过      更新时间:2023-09-26

enter code here我正在尝试将参数从js转换为php。我尝试通过ajax实现这一点,然后php需要接受参数并将其导出到xml文件而不是sql-so.

我在js中构建了simle脚本。我的代码js:

<input type="text" id="name" onkeyup="search()" />



请输入搜索词
<script>
function search()
{
    httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", "search.php?q="+document.getElementById('name').value,  true);
        httpObject.send();
                }   
}

php文件serch.php

    <?php
$result_set = $_GET['q'];
echo ($result_set);
?>

Thx可获得任何帮助:-)

您可以使用SimpleXML将数据保存到PHP中的xml文件中。

以下是它的一些使用示例:

http://www.php.net/manual/en/simplexml.examples-basic.php

示例#9展示了如何设置xml元素,其他示例处理检索数据的各种方法。

SimpleXML很容易在代码中使用,但不适用于非常大的xml文件。对于非常大的xml文件,您将希望使用更高级的解析器,它不会一次加载整个文件(而是逐行加载,节省程序内存)。这些有点困难,你可以在这里阅读一篇:

http://www.php.net/manual/en/example.xml-structure.php

我建议现在使用SimpleXML,除非您需要导入一个非常大的xml数据库。