Josh Posted July 21, 2024 Share Posted July 21, 2024 I found a Lua-written lib for parsing XML. VS projects are XML files: https://github.com/manoelcampos/xml2lua Might be useful. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted February 12 Author Share Posted February 12 Using pugixml, here is some code for parsing a Visual Studio vcxproj file... auto buffer = LoadBuffer(filename); pugi::xml_document doc; pugi::xml_parse_result result = doc.load_buffer(buffer->Data(), buffer->GetSize()); if (result.status == pugi::xml_parse_status::status_ok) { for (auto child : doc.children()) { if (child != NULL and strcmp(child.name(), "Project") == 0) { Print(child.name()); for (auto subchild : child.children()) { if (strcmp(subchild.name(), "ItemGroup") == 0) { Print("ItemGroup"); for (auto subsubchild : subchild.children()) { if (strcmp(subsubchild.name(), "ClCompile") == 0) { auto attr = subsubchild.attribute("Include"); if (attr) { std::string s = attr.as_string(); if (ExtractExt(s) == "cpp") { Print(s); auto newnode = subchild.append_child("ClCompile"); newnode.append_attribute("Include").set_value("Source/Components/Monster/MONSTER2.cpp"); break; } } } } } } } } out: std::ostringstream oss; doc.save(oss); std::string s = oss.str(); Print(s); } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.