mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:47:35 +00:00
LibXML: Add a fairly basic XML parser
Currently this can parse XML and resolve external resources/references, and read a DTD (but not apply or verify its rules). That's good enough for _most_ XHTML documents as the HTML 5 spec enforces its own rules about document well-formedness, and does not make use of XML DTDs (aside from a list of predefined entities). An accompanying `xml` utility is provided that can read and dump XML documents, and can also run the XML conformance test suite.
This commit is contained in:
parent
06cedf5bae
commit
67357fe984
15 changed files with 2895 additions and 0 deletions
40
Userland/Libraries/LibXML/DOM/Node.h
Normal file
40
Userland/Libraries/LibXML/DOM/Node.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibXML/FundamentalTypes.h>
|
||||
|
||||
namespace XML {
|
||||
|
||||
struct Attribute {
|
||||
Name name;
|
||||
String value;
|
||||
};
|
||||
|
||||
struct Node {
|
||||
struct Text {
|
||||
StringBuilder builder;
|
||||
};
|
||||
struct Comment {
|
||||
String text;
|
||||
};
|
||||
struct Element {
|
||||
Name name;
|
||||
HashMap<Name, String> attributes;
|
||||
NonnullOwnPtrVector<Node> children;
|
||||
};
|
||||
|
||||
bool operator==(Node const&) const;
|
||||
|
||||
Variant<Text, Comment, Element> content;
|
||||
Node* parent { nullptr };
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue