如何从html文本区域加载xml数据 [英] how to load xml data from html text area

查看:67
本文介绍了如何从html文本区域加载xml数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此表单页面:



 <?  php     $ this  -   > 负载>辅助( 'URL'); ?> 
< html >
< head >
< meta http-equiv = content-type content = text / html; charset = utf-8 / >
< link rel = stylesheet
type = text / css href = http://127.0.0.1/BL_ITCL/css/bootstrap.css >
< link rel = < span class =code-keyword> stylesheet type = text / css href = http://127.0.0.1/BL_ITCL/css/ bootstrap.min.css >
< link rel = stylesheet type = text / css < span class =code-attribute> href = http://127.0.0.1/BL_ITCL/ css / bootstrap-theme.css >
< link rel = 样式表 type = text / css href = http://127.0.0.1/BL_ITCL/css/bootstrap-theme.min.css\">
< title > 确认页面< / title >
< / head >
< body style = background-color:#F63; padding-left :443px; padding-top:127px; width:100% >
< div >
< 表格 action = http://127.0.0.1/BL_ITCL/index .php / Get_Request / request 方法 = 发布 >
< textarea 名称 = 请求 id = 请求 = 15 cols = 50 style = visibility:hidden; >

<? xml version = 1.0 < span class =code-summarycomment> encoding = ISO-8859-1 >
< span class =code-keyword>< data >
< 游戏 id = 103478 >
< 对手 > 彼得< / opponent >
< oppid > 4 < / oppid >
< lastdraw > 0 < / lastdraw >
< / game >
< 游戏 id = 10347 9 >
< 对手 > Peter < / opponent >
< oppid > 4 < / oppid >
< lastdraw > 2 < / lastdraw >
< / game >
< 游戏 id = 103483 >
< 对手 > James < / opponent >
< oppid > 47 < / oppid >
< lastdraw > 2 < / lastdraw >
< / game >
< / data >

< / textarea >
< br / >
< 输入 类型 = 提交 名称 = 确认 value < span class =code-keyword> = 确认 class = btn btn-success btn-lg >
< / form >
< / div >
< / body >
< / html >







我要加载xml和解析的另一个文件

 $ p = xml 
$ p = simplexml_load_file($ this- > input-> post(' Request'));
echo $ p-> data [0] - > opponent;

//创建错误



plz帮助任何身体

解决方案

this - > < /跨度>负载>辅助( 'URL'); ?>
< html >
< head >
< meta http-equiv = content-type content = text / html; charset = utf-8 / >
< link rel = stylesheet
type = text / css href = http://127.0.0.1/BL_ITCL/css/bootstrap.css >
< link rel = < span class =code-keyword> stylesheet type = text / css href = http://127.0.0.1/BL_ITCL/css/ bootstrap.min.css >
< link rel = stylesheet type = text / css < span class =code-attribute> href = http://127.0.0.1/BL_ITCL/ css / bootstrap-theme.css >
< link rel = 样式表 type = text / css href = http://127.0.0.1/BL_ITCL/css/bootstrap-theme.min.css\">
< title > 确认页面< / title >
< / head >
< body style = background-color:#F63; padding-left :443px; padding-top:127px; width:100% >
< div >
< 表格 action = http://127.0.0.1/BL_ITCL/index .php / Get_Request / request 方法 = 发布 >
< textarea 名称 = 请求 id = 请求 = 15 cols = 50 style = visibility:hidden; >

<? xml version = 1.0 < span class =code-summarycomment> encoding = ISO-8859-1 >
< span class =code-keyword>< data >
< 游戏 id = 103478 >
< 对手 > 彼得< / opponent >
< oppid > 4 < / oppid >
< lastdraw > 0 < / lastdraw >
< / game >
< 游戏 id = 10347 9 >
< 对手 > Peter < / opponent >
< oppid > 4 < / oppid >
< lastdraw > 2 < / lastdraw >
< / game >
< 游戏 id = 103483 >
< 对手 > James < / opponent >
< oppid > 47 < / oppid >
< lastdraw > 2 < / lastdraw >
< / game >
< / data >

< / textarea >
< br / >
< 输入 类型 = 提交 名称 = 确认 value < span class =code-keyword> = 确认 class = btn btn-success btn-lg >
< / form >
< / div >
< / body >
< / html >







另一个文件我要加载xml并解析

 


p = xml

p =使用simplexml_load_file(

this form page :

<?php $this->load->helper('url'); ?>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="http://127.0.0.1/BL_ITCL/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="http://127.0.0.1/BL_ITCL/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="http://127.0.0.1/BL_ITCL/css/bootstrap-theme.css">
    <link rel="stylesheet" type="text/css" href="http://127.0.0.1/BL_ITCL/css/bootstrap-theme.min.css">
    <title>Confirm Page</title>
</head>
<body style="background-color:#F63;padding-left:443px;padding-top:127px;width:100%" >
        <div>
            <form action="http://127.0.0.1/BL_ITCL/index.php/Get_Request/request" method="post">
                    <textarea  name="Request" id="Request" rows="15" cols="50" style="visibility: hidden;">

                       <?xml version="1.0" encoding="ISO-8859-1"?>
                            <data>
                              <game id="103478">
                                <opponent>Peter</opponent>
                                <oppid>4</oppid>
                                <lastdraw>0</lastdraw>
                              </game>
                              <game id="103479">
                                <opponent>Peter</opponent>
                                <oppid>4</oppid>
                                <lastdraw>2</lastdraw>
                              </game>
                              <game id="103483">
                                <opponent>James</opponent>
                                <oppid>47</oppid>
                                <lastdraw>2</lastdraw>
                              </game>
                            </data>

                    </textarea>
                <br/>
                   <input type="submit" name="confirm"  value="Confirm" class="btn btn-success btn-lg">
            </form>
        </div>
</body>
</html>




another file i want to load xml and parse

$p=xml
 $p=simplexml_load_file($this->input->post('Request'));
echo $p->data[0]->opponent;

// creates error

plz help any body

解决方案

this->load->helper('url'); ?> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="http://127.0.0.1/BL_ITCL/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="http://127.0.0.1/BL_ITCL/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="http://127.0.0.1/BL_ITCL/css/bootstrap-theme.css"> <link rel="stylesheet" type="text/css" href="http://127.0.0.1/BL_ITCL/css/bootstrap-theme.min.css"> <title>Confirm Page</title> </head> <body style="background-color:#F63;padding-left:443px;padding-top:127px;width:100%" > <div> <form action="http://127.0.0.1/BL_ITCL/index.php/Get_Request/request" method="post"> <textarea name="Request" id="Request" rows="15" cols="50" style="visibility: hidden;"> <?xml version="1.0" encoding="ISO-8859-1"?> <data> <game id="103478"> <opponent>Peter</opponent> <oppid>4</oppid> <lastdraw>0</lastdraw> </game> <game id="103479"> <opponent>Peter</opponent> <oppid>4</oppid> <lastdraw>2</lastdraw> </game> <game id="103483"> <opponent>James</opponent> <oppid>47</oppid> <lastdraw>2</lastdraw> </game> </data> </textarea> <br/> <input type="submit" name="confirm" value="Confirm" class="btn btn-success btn-lg"> </form> </div> </body> </html>




another file i want to load xml and parse


p=xml


p=simplexml_load_file(


这篇关于如何从html文本区域加载xml数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆