我是 MYSQL 的新手,我有一个酒店的 XML 文件,其中包括酒店代码和酒店描述。xml文件如下<hotels> <hotel> <hotelcode>1</hotelcode> <description>San cassiano residenzia D’epocaVenice’s Grand Canal.Overview Situated overlooking Venice’s Grand Canal, San Cassiano Residenzia D’Epoca is a historic hotel with plenty of charm</description> </hotel><hotel> <hotelcode>2</hotelcode> <description>San cassiano residenzia D’epocaVenice’s Grand Canal.Overview Situated overlooking Venice’s Grand Canal, San Cassiano Residenzia D’Epoca is a historic hotel with plenty of charm</description> </hotel><hotel> <hotelcode>3</hotelcode> <description>San cassiano residenzia D’epocaVenice’s Grand Canal.Overview Situated overlooking Venice’s Grand Canal, San Cassiano Residenzia D’Epoca is a historic hotel with plenty of charm</description> </hotel> <hotels>我还使用下面的 sql 查询将 xml 数据插入数据库$conn_1->query("LOAD DATA LOCAL INFILE '".$rs_file_path."' INTO TABLE hotels CHARACTER SET utf8 LINES STARTING BY '<hotel>' TERMINATED BY '</hotel>' (@tmp) SET hotelcode = ExtractValue(@tmp, 'hotelcode'), description= ExtractValue(@tmp, 'description') ;");但是这里的数据没有插入到酒店表中。因为 description 包含一些特殊字符,如 ',"" 等。有什么办法像 mysqli_real_escape_string
2 回答
慕的地8271018
TA贡献1796条经验 获得超4个赞
第二个引号字符是正确的单引号 ( ’
’
U+2019
)。
如果使用 XSLT,您可以使用translate()
函数替换它,例如:
<xsl:value-of select='translate(description, "’", "'")'/>
- 2 回答
- 0 关注
- 190 浏览
添加回答
举报
0/150
提交
取消