0

Maybe this is a stupid question but I need to get an Object with all HTML nodes from a selected html Page. I have to make all nodes selectable, especially the opening tags. If anyone know the template Engine from TYPO3 TemplaVoila; I think this suits it best but I would like to rebuilt it by myself but I don't have any Idea how to get all opening Tags into an Object.

If anyone can push some Details, actually, I'm testing around with domCrawler like this but it is a bit confusing....

 foreach ($crawler as $domElement) {
        foreach ($domElement as $test){
            var_dump($test->nodeName);
        }
        var_dump($domElement);
        $html .= $domElement->ownerDocument->saveHTML($domElement);
    }

So after some research, I am unsing HTMLPageDom and use it like that:

 $css= new HtmlPage();
    $css = new HtmlPage($head);
    $cssNew = $css->filter('link')->each(function ($node) {
        $node= $node->attr('href');
        return $node;
    });

So this works more or less but I'm thinking that I missunderstood something. How can I append data to $node->attr('href)? With:

$node->attr('href')->append('data in front of linkuri');
common sense
  • 3,775
  • 6
  • 22
  • 31
TheTom
  • 934
  • 2
  • 14
  • 40

2 Answers2

0

You can try by this way:

/.../

$values = $crawler->filterXpath('//body')->each(function ($node) {
    return $node->html();
});

/.../
scoolnico
  • 3,055
  • 14
  • 24
  • Thank you, I found out that pagecrwaler might be not for editing, only for reading. So i changed my question and updated it. Maybe you can help me going on? – TheTom Dec 01 '15 at 09:01
0

SOLUTION:

Ok at least I was thinking too weired :)

It's just so simple:

$body->filter('img')->setAttribute('src', $this->absPath.$bodySource->filter('img')->attr('src') );
TheTom
  • 934
  • 2
  • 14
  • 40