From b40ab558303fd19a159dabba49f0b51e5889d527 Mon Sep 17 00:00:00 2001 From: Dan Klishch Date: Mon, 14 Aug 2023 21:01:50 -0400 Subject: [PATCH] LibXML: Add helpers for extracting node contents if its type is known --- Userland/Libraries/LibXML/DOM/Node.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Userland/Libraries/LibXML/DOM/Node.h b/Userland/Libraries/LibXML/DOM/Node.h index b36e7c6e77..aed1b9f4db 100644 --- a/Userland/Libraries/LibXML/DOM/Node.h +++ b/Userland/Libraries/LibXML/DOM/Node.h @@ -36,5 +36,14 @@ struct Node { Variant content; Node* parent { nullptr }; + + bool is_text() const { return content.has(); } + Text const& as_text() const { return content.get(); } + + bool is_comment() const { return content.has(); } + Comment const& as_comment() const { return content.get(); } + + bool is_element() const { return content.has(); } + Element const& as_element() const { return content.get(); } }; }