C++与 xmlwriter 结合使用的列表
我的问题是使用 XmlWriter 在 C++ 中输出列表。我需要一个可以包含在我的 XML 文件中的列表。我计划的代码 - 应该实现一个类来生成列表元素,但我不知道为什么:
writer->WriteStartElement( "Parameters" );
writer->WriteStartElement( "ParamterList" );
// A list including approximately 100 entries
writer->WriteAttributeString( "ID", "001" );
writer->WriteAttributeString( "Name", "Dummy1" );
writer->WriteAttributeString( "BitOffset", "0" );
writer->WriteEndElement();
writer->WriteEndElement();
如何将列表插入到我的应用程序中。我的输出应该是这样的:
<root Name="database" Purpose="test" Project="test">
<Description Version="1.1B" Author="name">test</Description>
<ContainerList>
<Container Name="Dummy1" BitOffset="0" />
</ContainerList>
<ParameterList>
<Paramter ID="001" Name="Dummy1" BitOffset="0" />
<Paramter ID="002" Name="Dummy2" BitOffset="1" />
<Paramter ID="003" Name="Dummy3" BitOffset="0" />
<Paramter ID="004" Name="Dummy4" BitOffset="0" />
......
</ParameterList>
由于答案1中显示的代码,我现在知道如何将列表与XmlWriter一起使用,但目前我真的不知道如何连接并为此代码编写一个类?
My problem is to output a list in C++ using XmlWriter. I need a list wich can be included in my XML file. My planned code - A class should be implemented to generate the list elements, but I don't know why:
writer->WriteStartElement( "Parameters" );
writer->WriteStartElement( "ParamterList" );
// A list including approximately 100 entries
writer->WriteAttributeString( "ID", "001" );
writer->WriteAttributeString( "Name", "Dummy1" );
writer->WriteAttributeString( "BitOffset", "0" );
writer->WriteEndElement();
writer->WriteEndElement();
How is it possible to insert a list into my application. My output should look like this:
<root Name="database" Purpose="test" Project="test">
<Description Version="1.1B" Author="name">test</Description>
<ContainerList>
<Container Name="Dummy1" BitOffset="0" />
</ContainerList>
<ParameterList>
<Paramter ID="001" Name="Dummy1" BitOffset="0" />
<Paramter ID="002" Name="Dummy2" BitOffset="1" />
<Paramter ID="003" Name="Dummy3" BitOffset="0" />
<Paramter ID="004" Name="Dummy4" BitOffset="0" />
......
</ParameterList>
Due to the code shown in answer 1, I now know how to use a list with XmlWriter, but at the moment I don't really know how to connect and write a class for this code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每个
Paramter
(您拼写正确吗?)元素都是一个 XML 元素。因此,它需要一个WriteStartElement
调用和一个WriteEndElement
。在这些调用中,您可以添加您的 ID 和其他属性。所以你的清单将是这样的:Each
Paramter
(did you spell that correctly?) element is an XML element. Therefore, it needs aWriteStartElement
call and aWriteEndElement
. Within those call, you add your IDs and other attributes. So your list would be something like this: