-1
我需要做的蟒蛇任何幫助,從XML文件中的代碼檢查調制解調器的狀態和激活服務,如果不OK我需要做這個Python的任何想法
XML實例
<SMSCStatus>
<Name>HUAWEI Mobile Connect - 3G Modem</Name>
<Status>ERROR</Status>
<StatusDetail>
Modem Failure -- Unable to access modem, ensure that it is powered on and passes diagnostic tests.
</StatusDetail>
<MessagesToday>0</MessagesToday>
<MessagesLast7Days>0</MessagesLast7Days>
<MessagesLast30Days>0</MessagesLast30Days>
</SMSCStatus>
<?php
$xml = simplexml_load_file("xmlfile");
$status1 = $xml->SMSCStatus->Status;
if ($status1 == "OK")
{
$fp = fopen("status.txt", "w");
fwrite($fp, "2");
fclose($fp);
}
else
{
$statusr = json_encode(array(
'server' => 'TOO FAIL'
));
echo exec('net start "NowSMS"');
}
?>
StackOverflow不是這個問題的適當位置。我們不會爲您編寫代碼。你需要做自己的編碼,如果你不確定爲什麼某些東西不能按預期工作,請在代碼中加上一個解釋你期望它做什麼,以及它實際上在做什麼,包括所有的錯誤信息。看[ask advice](http://stackoverflow.com/questions/ask-advice)。 –
我只是需要一個例子。如何做到這一點 $ xml = simplexml_load_file(「xmlfile」); $ status1 = $ xml-> SMSCStatus-> Status;用python不寫我的代碼 –
看看[在標準庫中可用於解析XML的模塊](http://docs.python.org/3.3/library/markup.html)。 – icktoofay