2012-05-30 73 views
0

我使用TouchXML解析WSDL文件,以獲得從WSDL文件中的數據,而我是一個新手的話,有這樣如何使用touchxml

NSString *str = @"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soap:Body><ns1:createSessionResponse xmlns:ns1=\"http://soap.user/\"><ns1:out>9E0B34E6DFF7BF89</ns1:out></ns1:createSessionResponse></soap:Body></soap:Envelope>";

我怎樣才能得到一個的NSString在串9E0B34E6DFF7BF89 「NS:走出」

回答

0

試試這個:

NSString *str = @"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soap:Body><ns1:createSessionResponse xmlns:ns1=\"http://soap.user/\"><ns1:out>9E0B34E6DFF7BF89</ns1:out></ns1:createSessionResponse></soap:Body></soap:Envelope>"; 
NSRange rr2 = [str rangeOfString:@"<ns1:out>"]; 
NSRange rr3 = [str rangeOfString:@"</ns1:out>"]; 
int lengt = rr3.location - rr2.location - rr2.length; 
int location = rr2.location + rr2.length; 
NSRange aa; 
aa.location = location; 
aa.length = lengt; 
str = [str substringWithRange:aa]; 
NSLog(@"%@",str); // 9E0B34E6DFF7BF89 
+0

喔...你想使用TouchXML? – Hector

+0

你有解決辦法嗎? – Hector

+0

謝謝Hector,我找到另一種直接獲得會話價值的方法。但你的回答對我仍然有幫助。 – user1425054