douchuituo3032 2015-10-07 15:07
浏览 42
已采纳

从mysql中检索xml文件并将其用作php中的变量

I'm retrieving an XML code from the database and storing it as a variable in php. However when I try to use this variable inside an XML code, it gives me an error. Here is my code:

<?php

          $conn = mysqli_connect('localhost', 'root', '', 'thisdatabase');
          $result = mysqli_query($conn, 'SELECT * FROM createdproduct');
          while ($row = mysqli_fetch_assoc($result))
          {
            //$selected = (isset($_POST['list']) && $_POST['list'] ==  $row['id']) ? 'selected' : '';
              //echo htmlentities($row["productURL"]);
              $test = htmlspecialchars($row["productURL"]);
          }


          //echo htmlentities($test);
?>

and this is my XML wrapped in php:

<?php
//some code

    $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <order xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://api.mydomain.net">
        <orderItems>
            '.$test.'
        </orderItems>
        <payment>
            <type>typ</type>
        </payment>
<shipping>
    <shippingType id="00"/>
     <address type="private">
        <person> <
            <salution id="1"/>
            <firstName>person</firstName>
            <lastName>person</lastName>
        </person>
        <street>street</street>
        <houseNumber>00</houseNumber>
        <city>city</city>
        <country code="US">USA</country>
        <state code="mm">California</state>
        <zipCode>111</zipCode>
        <email>aaa@mydomain.net</email>
        <phone>+49 341 789 123</phone>
        <fax>+49 341 789 123</fax>
    </address>
</shipping>
    </order>';
//some code

?>
  • 写回答

2条回答 默认 最新

  • dsgft1486 2015-10-08 10:35
    关注

    I was able to get the result I wanted using html_entity_decode. Thank you

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?