== How to fix it in libxml2

=== Code examples

include::../../common/fix/code-rationale.adoc[]

==== Noncompliant code example

[source,cpp,diff-id=1,diff-type=noncompliant]
----
#include "libxml/parser.h"

void parse() {
  xmlDocPtr doc = xmlReadFile(xmlFile, nullptr, XML_PARSE_DTDLOAD | XML_PARSE_NOENT); // Noncompliant
}
----


==== Compliant solution

By default, `xmlReadFile` is safe since version 2.9.

[source,cpp,diff-id=1,diff-type=compliant]
----
#include "libxml/parser.h"

void parse() {
  xmlDocPtr doc = xmlReadFile(xmlFile, nullptr, 0);
}
----

=== How does this work?

include::../../common/fix/xxe.adoc[]
