我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

PHP DOMnode。 如何检查是否配对?

I have some tags in XML document:

      <kat1>42</kat1>
      <kat2/>
      <kat3/>

and if DOMNode $myNode is "kat2"

$myNode->nodeValue

returns zero instead of null. How to check if it is not paired tag and return NULL if true, else value.

Demo

<tag /> is the exact same thing as <tag></tag> so, all you have to do is check whether or not it's empty. If it's empty it wil be printed as a single tag, if it's not empty it will be be printed with both opening and closing tags.

近期文章

  • 将变量传递给symfony和jquery中的字符串
  • 通过PHP cURL连接时出现SSL3_READ_BYTES错误
  • 构造函数中的对象初始化(php 5.5)
  • Phpinfo()显示了旧版本的Mysql Centos 6.7
  • 使用PHPExcel_IOFactory :: load($ file)不存在文件
  • 显示无,但内容仍显示在检查器中
  • 群组受众列表在“有机组”中显示“无”
  • 将更新的产品价格推送到Opencart 2.x中的过去订单
  • 使用PHP通过cPanel创建mysql DB并导入* .sql文件
  • 验证整理的PHP文件与原始文件相同
  • 避免SQL注入在几秒钟内插入数千条记录
  • 优化Switch案例PHP
  • MySQL表连接:一个记录,两个字段,另一个表中的id
  • 从php出来的Json正在添加一些额外的字符
  • AJAX和PHP崩溃服务器
  • Joomla 3.4.4。 tmp目录
  • php将json传递给angularjs
  • Laravel查询无法正常工作
  • 从服务器发送邮件时出错?
  • Zend \ Db \ Sql \选择使用函数作为表

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华