普通网友 2015-02-18 06:03
浏览 21
已采纳

什么归类为html标签上的Child?

I want to parse this and need to know the number of children has. I am told that comments should also count as children. I am confused as to count all tags inside the parent as children?

<div class="event">
                <h4>Northland Outdoors Duluth Deer Classic</h4>
                <span class="timestamp" style="display: none;">1424282400</span>        
                <p class="date"><span class="month">February</span> 18, <span class="year">2015</span>  </p>    <table><tr><td class="field-name">Location:</td>
                <td class="location">
                    <span class="city">Duluth</span>, 
                    <span class="state">MN</span>, Duluth Entertainment Convention Center</td><td><tr><td class="field-name">Description:</td><td>Join us at the Northland Outdoors Duluth Deer Classic February 18th - 20th, 2015, which will again be held in conjunction...
                <a href="/events/details/northland-outdoors-duluth-deer-classic2" title="View listing detail">View more detail &raquo;</a></td></tr><tr><td class="field-name">Types of Vendor:</td><td>
                <ul class="vendors"><li class="allowed art">Art</li><li class="allowed craft">Craft</li><li class="allowed commercial">Commercial</li></ul>         </td></tr></table><div class="clear"></div></div>
  • 写回答

1条回答 默认 最新

  • doujia4619 2015-02-18 07:44
    关注

    once you parse the event class by DOM/Curl its convert the String to the nodes objects. the Objects are called to all the breaking points ie. or . the each node can also contain other childs such as

    <div class= 'event'> <p class='class2'>something here</p></div>
    

    In this format the class2 is a subclass or a child of the class event.The best way of parsing the html is look (search) by class name or href ... and don't use direct path to the target section. It is more safe and efficient in parsing. On the other hand the best way to identify the child are just counting the direct/major opening and closing section < ></>

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

报告相同问题?

悬赏问题

  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行