如何使用 C 从 Xml 获取属性值

How to get attribute value from Xml using C

我有 XML 文件,如下所示

 -<fmiModelDescription numberOfEventIndicators="0" variableNamingConvention="structured" generationDateAndTime="2015-06-22T14:46:19Z" generationTool="Dassault Systemes FMU Export from Simulink, ver. 2.1.1 (MATLAB 8.7 (R2014b) 08-Sep-2014)" version="1.4" author="Dan Henriksson" description="S-function with FMI generated from Simulink model BouncingBalls" guid="{76da271a-0d11-469c-bc24-0343629fb38e}" modelName="BouncingBalls_sf" fmiVersion="2.0"> <CoSimulation canHandleVariableCommunicationStepSize="true" modelIdentifier="BouncingBalls_sf"/> <DefaultExperiment stepSize="0.001" stopTime="10.0" startTime="0.0"/> -<ModelVariables>

我想获取上面给出的例如 GUID 的属性值 XML,我如何使用 C 编程来做到这一点

嗯,唯一有效的答案是:使用库

可能最好的(就功能完整性而言)是 libxml。如果没有任何其他问题,请使用它。也有很好的文档。

如果您需要一些小东西,有很多选择,但都有其局限性。我最近创建了 badxml for this purpose. There are many other options, such as ezxml,这是我今天在这里的一个问题中发现的。

但正如我所说,如果大小不是问题,只需使用 libxml,因为它被广泛使用、经过良好测试且功能齐全。