I need to parse .vcproj file in Qt, this file actually xml file adn looks like:
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject...>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
>
...
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
...
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
...
</Filter>
<Filter
Name="CppOp"
>
...
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
I need to get all configurations names, i use this:
QFile* file = new QFile(xmlFile);
if (file->open(QIODevice::ReadOnly | QIODevice::Text)) {
QXmlStreamReader xml(file);
while (!xml.atEnd() && !xml.hasError()){
QXmlStreamReader::TokenType token = xml.readNext();
if (token == QXmlStreamReader::StartDocument)
continue;
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "Configurations")
continue;
if (xml.name() == "Configuration") {
QXmlStreamAttributes attributes = xml.attributes();
if (attributes.hasAttribute("Name"))
ui->prefferedConfigSelectComboBox->addItem(attributes.value("Name").toString());
}
}
}
}
I try to use http://developer.nokia.com/Community/Wiki/QXmlStreamReader_to_parse_XML_in_Qt . It's look like that QXmlStreamReader do not "see" Name attribute in this file. But it doesn't work, and I don't know why.