如何從xml標記中提取值? 下面是存儲在指針變量響應中的XML。要從C語言的XML標記中獲取值
<Response>
<ID>App1</ID>
<operationID>654164615</operationID>
<mainReturnResult>
<returnCode>2000</returnCode>
<returnString> Success – Successful Result </returnString>
</mainReturnResult>
<totalDuration>647</totalDuration>
<Result>
<jobID>job1</jobID>
<mainReturnResult>
<returnCode>2000</returnCode>
<returnString> Success – Successful Result </returnString>
</mainReturnResult>
<duration>78</duration>
/*still more xml tags*/
-Data.to.be.taken
data comes here which have to extracted
-Done.with.data
我只需要返回碼和xml結尾的數據。 我正在使用strstr來獲取標記返回碼的值。但是當我的朋友看到我這樣做時,他說這是一個不好的方法。 但是,我只需要 1.返回代碼知道狀態和 2.從xml中提取數據。
所以,你可以請我建議,這是做這兩個活動的有效方式,而不使用任何庫。
爲什麼沒有任何圖書館?正確的方法是使用libxml。 – 2012-07-05 18:19:35
@ H2CO3我們不能沒有lib?我只需要兩個值。 – sach 2012-07-05 18:24:35
沒有圖書館這樣做比使用圖書館更復雜。 – 2012-07-05 18:26:24