PHP code example of artem14133q / sxml

1. Go to this page and download the library: Download artem14133q/sxml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

artem14133q / sxml example snippets


use Sxml\Documents\HtmlDocument;

$html = "
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div>Hello World!</div>
</body>
</html>
";

$doc = HtmlDocument($html);

$body = $doc->getHtmlNode()->findByName("body")[0];
$div = $body->findByName("div")[0];

$div->setValue("Hello SXML!");

$doc->writer->asText();