我使用QProcess运行xmllint,代码如下:
QString program = "xmllint";
QStringList arguments;
arguments << "--xpath";
arguments << "\"//table_data[@name='" + tableToSearch + "']./row[./field[@name='rowuuid' and . = '" + UUIDToSearch + "']]\"";
arguments << dataFile;
QProcess *myProcess = new QProcess();
myProcess->start(program, arguments);
myProcess->waitForFinished(-1);
QString serror = myProcess->readAllStandardOutput();
QString serror2 = myProcess->readAllStandardError();
如果我在终端中运行相同的命令,我会得到:
<row>
<field name="surveyid">782be47c-2f05-430c-adb9-29fd0631417d</field>
<field name="originid">FORMHUB-JSON</field>
<field name="meta_devid">865770021186061</field>
<field name="start_time">2017-06-06 11:23:36</field>
<field name="survey_date">2017-06-06 00:00:00</field>
<field name="date_yyyymmdd">20170606</field>
<field name="subscriber_id">640021068988925</field>
<field name="phone_number" xsi:nil="true"/>
<field name="end_time">2017-06-06 12:54:58</field>
<field name="onfarm_country">T</field>
<field name="onfarm_subnatarea">CS</field>
<field name="onfarm_village">105</field>
<field name="onfarm_enum">105</field>
<field name="householdid">TCS1500</field>
<field name="householdid_key">TCS1500_20170606</field>
<field name="bent_general">0</field>
<field name="bext_general">1</field>
<field name="rowuuid">b93c6113-7508-42aa-8549-267f0956b935</field>
</row>
但myProcess-&gt; readAllStandardOutput()返回:
//table_data[@name='birdentext_maintable']./row[./field[@name='rowuuid' and . = 'b93c6113-7508-42aa-8549-267f0956b935']]
我修改了代码以使用readyReadStandardError信号,以防以后发送更多数据,但我得到相同的信息。
知道这里发生了什么吗?