Implementation:CARLA simulator Carla Pugixml
| Knowledge Sources | |
|---|---|
| Domains | XML Parsing, Data Serialization |
| Last Updated | 2026-02-15 05:00 GMT |
Overview
pugixml.cpp is the implementation file for the pugixml XML parser library (version 1.9), providing the complete XML parsing, DOM manipulation, XPath query, and serialization functionality used by CARLA.
Description
This is a third-party library by Arseny Kapoulkine distributed under the MIT license. The implementation file (~12806 lines) contains the full parser implementation including: XML tokenizing and parsing, DOM tree construction, node/attribute manipulation, XPath expression evaluation, and XML serialization/output. The library supports both char and wchar_t modes via the PUGIXML_WCHAR_MODE define, and can optionally disable STL support (PUGIXML_NO_STL) or XPath (PUGIXML_NO_XPATH). CARLA uses this library primarily for parsing OpenDRIVE road network files which are XML-based.
Usage
This file is compiled as part of the LibCarla build. Client code should include pugixml.hpp rather than this implementation file directly.
Code Reference
Source Location
- Repository: CARLA
- File:
LibCarla/source/third-party/pugixml/pugixml.cpp
Signature
// pugixml parser - version 1.9
// Copyright (C) 2006-2018, by Arseny Kapoulkine
// MIT License
#include "pugixml.hpp"
// Full implementation of:
// - XML parsing (SAX-like tokenizer + DOM builder)
// - DOM tree manipulation
// - XPath evaluation engine
// - XML serialization/output
Import
// Do not include pugixml.cpp directly. Use the header:
#include "third-party/pugixml/pugixml.hpp"
I/O Contract
| Component | Input | Output | Description |
|---|---|---|---|
| XML Parser | Raw XML string or file | xml_document DOM tree |
Parses XML data into an in-memory document tree |
| DOM API | Node/attribute queries | Node values, children, attributes | Navigates and manipulates the parsed document |
| XPath Engine | XPath expression string | Node set or value | Evaluates XPath queries against the DOM |
| Serializer | xml_document |
Formatted XML string/stream | Outputs the DOM tree as formatted XML text |
Usage Examples
#include "third-party/pugixml/pugixml.hpp"
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file("opendrive_map.xodr");
if (result) {
pugi::xml_node root = doc.child("OpenDRIVE");
for (auto road : root.children("road")) {
std::string name = road.attribute("name").as_string();
// process road data
}
}