doudieheng5322 2012-03-21 04:00
浏览 58
已采纳

解析HTML并显示结果

is there a function in PHP that could parse the html data below to show the following.

John Lastname
my address
24
1998-03-20 8:15:31 pm
anything
1.1.1.1

This is the html

<b>Name:</b> John Lastname<br />
<b>Address:</b> [my address] <br />
<b>Age:</b> [24] <br/><br />
<b>Date of Birth:</b> [1998-03-20 8:15:31 pm] <br />
<b>Hobby:</b> [anything]<br /> <b>StudentID:</b>[1.1.1.1] <br /><br />
  • 写回答

1条回答 默认 最新

  • drtoaamk20278 2012-03-21 04:27
    关注

    You should be able to use the DOMDocument extension to parse the HTML.

    Having said that, your snippet does not look very semantic at all, so perhaps regex might be a better option.

    See this question for a comprehensive example on how to parse it with DOMDocument.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事: