DocWire SDK
DocWire SDK: Deterministic, auditable, and secure data processing in C++20. On-premise by default. No compromises on computational speed.
Loading...
Searching...
No Matches
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
20namespace docwire::xml
21{
22
31template <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.
A forward-only, non-cached XML reader.
Definition xml_reader.h:64
XML processing utilities.
children_view< safety_level > children(const node_ref< safety_level > &node)
Returns a view of the direct children of the given node.
node_ref< safety_level > root_element(reader< safety_level > &reader)
Finds and returns the root element of the XML document.
Uninterpretable data error tag.
Definition error_tags.h:88