// Затем просматривать элементы "animal", пытаясь найти элемент слона
// Herby.
DOMNodeList* animals =
animaIList->getElementsByTagName(fromNative("animal").c_str());
for (size_t i = 0,
len = animals->getLength(); i < len; ++i) {
DOMElement* animal =
static_cast<DOMElement">(animals->item(i));
const XMLCh* name = getAnimalName(animal);
if (name != 0 && name == fromNative("Herby")) {
// Herby найден - удалить его из документа.
animalList->removeChild(animal);
animal->release();
// необязательный оператор.
break;
}
}
// Сконструировать DOMWriter для сохранения animals.xml.
DOMPtr<DOMWriter> writer =
static cast<DOMImplementationLS*>(impl)->createDOMWriter();
writer->setErrorHandler(&err);
// Сохранить animals.xml.
LocalFileFormatTarget file("animals.xml");
writer->writeNode(&file, *animalList);
} catch (const SAXException& e) {
cout << "xml error: " << toNative(e.getMessage()) << "\n";
return EXIT_FAILURE;
} catch (const DOMException& e) {
cout << "xml error: " << toNative(e.getMessage()) << "\n";
return EXIT_FAILURE;