loadXML - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of loadXML.php
- <?php
- /**
- * @param string $xmlContent A well-formed XML string
- * @param string $version 1.0
- * @param string $encoding utf-8
- * @return bool
- */
- function isXMLContentValid($xmlContent, $version = '1.0', $encoding = 'utf-8'){
- if (trim($xmlContent) == '') {
- return false;
- }
- libxml_use_internal_errors(true);
- $doc = new DOMDocument($version, $encoding);
- $doc->loadXML($xmlContent);
- $errors = libxml_get_errors();
- libxml_clear_errors();
- return empty($errors);
- }
- $xml = '<website><domain>wtools.io</domain><title>Online Web Tools</title></website>';
- if(isXMLContentValid($xml)){
- echo "Valid XML string";
- } else {
- echo "Not valid JSON string";
- }
File Description
- loadXML
- PHP Code
- 18 Dec-2020
- 691 Bytes
You can Share it:
Latest PHP Pastes