PHP DomCrawler,基于特定父级获取子节点

时间:2015-07-31 11:47:01

标签: php symfony web-crawler domcrawler

根据特定父级获取子节点

var coord = "(51.01407864998378, 4.15557861328125)";
Match match = Regex.Match(coord, @"\(([\d]*.[\d]*),[^\d]*([\d]*.[\d]*)\)$", RegexOptions.IgnoreCase);

if (match.Success)
{
      decimal lng = Convert.ToDecimal(match.Groups[1].Value, CultureInfo.GetCultureInfo("en-US"));
      decimal lat = Convert.ToDecimal(match.Groups[2].Value, CultureInfo.GetCultureInfo("en-US"));

      Console.WriteLine(lng);
      Console.WriteLine(lat);
}

如何让function(Crawler $node,){ $node->filter('this>ul'); } 个孩子不包含像CSS选择器$node这样的孙子?

1 个答案:

答案 0 :(得分:2)

  1. 您正在使用CSS选择器。
  2. CSS中没有thisparent选择器。
  3. 您应该只使用$node->filter('>ul');