From 0be52b8bd90401d6110d0303c695dfc5d8f9f63f Mon Sep 17 00:00:00 2001
From: Jose Luis Vazquez-Garcia <jose.vazquez@xfel.eu>
Date: Thu, 6 Feb 2025 14:18:32 +0100
Subject: [PATCH] Improve comments

---
 source/loading_file.rst | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 source/loading_file.rst

diff --git a/source/loading_file.rst b/source/loading_file.rst
new file mode 100644
index 0000000..2065906
--- /dev/null
+++ b/source/loading_file.rst
@@ -0,0 +1,26 @@
+.. _loadfile:
+
+**************************************
+Loading an xml file into a Karabo Hash
+**************************************
+
+The next code example shows hot to load the content of an XML file into a Karabo
+Hash:
+
+.. code-block:: c++
+
+    // We assume the file is inside the Karabo installation
+    std::string file_path(karabo::util::Version::getPathToKaraboInstallation() + "/var/data/my_file.xml");
+    try {
+        
+        // Load the content of the file into 'config'.
+        // This is protected in a try-catch block, in case something is wrong (the file format can be
+        // corrupt, for instance)
+        Hash config;
+        Input<Hash>::Pointer input = Input<Hash>::create("TextFile", Hash("filename", file_path));
+        input->read(config);
+
+    } catch (std::exception& e) {
+        KARABO_LOG_FRAMEWORK_WARN << "Failed to load File: " << file_path << " : " << e.what();
+    }
+
-- 
GitLab