How to some div value export to xml with tag in php code.
I search my site and from div value export to external xml file.

?php
$some_link = 'http://www.popusti.rs/';
$tagName = 'div';
$attrName = 'class';
$attrValue = 'offer-list-item';

$dom = new DOMDocument;
$dom->preserveWhiteSpace = false;
@$dom->loadHTMLFile($some_link);

$html = getTags( $dom, $tagName, $attrName, $attrValue );
echo $html;

function getTags( $dom, $tagName, $attrName, $attrValue ){
    $html = '';
    $domxpath = new DOMXPath($dom);
    $newDom = new DOMDocument;
    $newDom->formatOutput = true;

    $filtered = $domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']");
     $filtered =  $domxpath->query('//div[@class="offer-list-item"]');
    // '//' when you don't know 'absolute' path


    $i = 0;
    while( $myItem = $filtered->item($i++) ){
        $node = $newDom->importNode( $myItem, true );   
        $newDom->appendChild($node);                   
    }
    $html = $newDom->savehtml();
    return $html;
}

?>
Member Avatar for diafol

How to some div value export to xml with tag in php code.
I search my site and from div value export to external xml file.

This doesn't make much sense. Perhaps if you rephrase the question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.