if (buffer.Size() > static_cast(std::numeric_limits::max())) { log.Info("Cannot create XML reader: String to large"); return; } void* pReader = xmlReaderForMemory(buffer.CStr(), static_cast(buffer.Size()), "", "UTF-8", 0); if (pReader == nullptr) { log.Info("Could not create XML Reader for memory."); return; } log.Info("Created XML Reader for memory."); // read the next element log.Info("Reading the first element."); int res = xmlTextReaderRead((xmlTextReaderPtr)pReader); if (res == 1) { // successful moved to the next element } else if (res == 0) { // end of file reached log.Info("End of file reached."); return; } else { log.Info("Read failed: xmlTextReaderRead failed"); return; } xmlChar* localName = xmlTextReaderLocalName((xmlTextReaderPtr)pReader); if (localName != NULL) { log.Info("Local name of first element: {0}", (char*)localName); } // read the next element log.Info("Reading the second element."); res = xmlTextReaderRead((xmlTextReaderPtr)pReader); if (res == 1) { // successful moved to the next element } else if (res == 0) { // end of file reached log.Info("End of file reached."); return; } else { log.Info("Read failed: xmlTextReaderRead failed"); return; } localName = xmlTextReaderLocalName((xmlTextReaderPtr)pReader); if (localName != NULL) { log.Info("Local name of second element: {0}", (char*)localName); } // read the next element log.Info("Reading the third element."); res = xmlTextReaderRead((xmlTextReaderPtr)pReader); if (res == 1) { // successful moved to the next element } else if (res == 0) { // end of file reached log.Info("End of file reached."); return; } else { log.Info("Read failed: xmlTextReaderRead failed"); return; } localName = xmlTextReaderLocalName((xmlTextReaderPtr)pReader); if (localName != NULL) { log.Info("Local name of third element: {0}", (char*)localName); }