DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
xml_root_element.h
1 /*********************************************************************************************************************************************/
2 /* DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. */
3 /* Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, */
4 /* document analysis. Offline processing possible for security and confidentiality */
5 /* */
6 /* Copyright (c) SILVERCODERS Ltd, http://silvercoders.com */
7 /* Project homepage: https://github.com/docwire/docwire */
8 /* */
9 /* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-DocWire-Commercial */
10 /*********************************************************************************************************************************************/
11 
12 #ifndef DOCWIRE_XML_ROOT_ELEMENT_H
13 #define DOCWIRE_XML_ROOT_ELEMENT_H
14 
15 #include "xml_children.h"
16 #include "xml_node_ref.h"
17 #include "make_error.h"
18 #include "error_tags.h"
19 
20 namespace docwire::xml
21 {
22 
31 template <safety_policy safety_level>
33 {
34  for (auto node: children(reader))
35  {
36  if (node.type() == node_type::element)
37  return node;
38  }
39  throw DOCWIRE_MAKE_ERROR("No root element found", docwire::errors::uninterpretable_data{});
40 }
41 
42 }
43 
44 #endif // DOCWIRE_XML_ROOT_ELEMENT_H
A reference to the current XML node in the reader.
Definition: xml_node_ref.h:33
XML processing utilities.
node_ref< safety_level > root_element(reader< safety_level > &reader)
Finds and returns the root element of the XML document.
children_view< safety_level > children(const node_ref< safety_level > &node)
Returns a view of the direct children of the given node.
Definition: xml_children.h:119
Uninterpretable data error tag.
Definition: error_tags.h:88