showDoc("After update 'newtag/@someatt', 'attval'");
$testdoc->xmd_update('newtag/~', '');
showDoc("After update 'newtag/~', ''");
$keepdoc = $testdoc;
$wrongdoc = "<html>\n  <body>\n    <p>Text</p>\n    <p>More text" . "\n  </body>\n</html>";
$testdoc = new xmddoc(explode("\n", $wrongdoc));
showDoc('Xml doc with syntax error + error message', $wrongdoc . "\n\n" . $testdoc->error);
$xmlFile = 'imsmanifest_reload.xml';
$presXmlFileContents = @file_get_contents_n($xmlFile) or die('XML file  ' . htmlspecialchars($xmlFile) . ' is missing...');
showDoc('XML file to be parsed', $presXmlFileContents);
$testdoc = new xmddoc(explode("\n", $presXmlFileContents));
unset($presXmlFileContents);
if ($testdoc->error) {
    die($xmlFile . ':<br><br>' . $testdoc->error);
}
$testdoc->xmd_update_many('metadata/lom/general/title,metadata/lom/general/description', 'langstring/@lang', 'fr');
$testdoc->xmd_copy_foreign_child($keepdoc, $keepdoc->xmd_select_single_element('sometag[2]'));
showDoc('After parsing, and after changing 2* langstring/@lang to fr, ' . 'and after adding a foreign doc, reconstruction from memory');
showDoc('Element tagname of first metadata/lom/* element', $testdoc->name[$testdoc->xmd_select_single_element('metadata/lom/*')]);
showDoc('Element namespace URI of metadata/lom/*[2]', $testdoc->xmd_get_ns_uri($testdoc->xmd_select_single_element('metadata/lom/*[2]')));
showDoc('Number of metadata/lom/* elements', count($testdoc->xmd_select_elements('metadata/lom/*')));
showDoc('Number of resources/resource/file elements with @href', count($testdoc->xmd_select_elements_where_notempty('resources/resource/file', '@href')));
$elems = $testdoc->xmd_select_elements_where('resources/resource', 'file[1]/@href', 'three.html');
showDoc('Resource identifier where file[1]/@href is three.html', $testdoc->xmd_value('@identifier', $elems[0]));
$elems = $testdoc->xmd_select_elements_where('resources/resource', '@identifier', $testdoc->xmd_value('organizations/organization/item[2]/@identifierref'));
showDoc('Resource href for item[2]', $testdoc->xmd_value('@href', $elems[0]));
$stuff = '';
foreach (array('@identifier', 'metadata/schema', '*/*/*/*[1]/langstring', 'resources/resource[3]/@href', 'resources/resource[3]/file/@href', 'resources/resource[3]/@*', 'resources/resource[3]/-/@href', 'resources/resource[3]/+/@href', 'resources/resource[1]/-/@href', 'resources/../../../../../../../@identifier', '@*', 'resources/@*', 'organizations/organization/item[4]/title', 'organizations/organization/item[-2]/title', 'organizations/organization/item[4]/@*', 'organizations/organization/item[4]/@*item', 'organizations/organization/item[2]/+item/title', 'organizations/organization/item[2]/+/+/+/title', 'organizations/organization/item[2]/-item', 'organizations/organization/item[1]/-item', 'organizations/organization/item[1]/-', 'organizations/organization/item[1]/-/@.') as $path) {
    $stuff .= $path . ' => ' . $testdoc->xmd_value($path) . "\n";
}
showDoc('Values of: @identifier, metadata/schema, ... (see below)', $stuff);