Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 iOS 中用 TBXML 解析这个 xml 时遇到了困难:
<ServiceResponse><Response> <Object type="java.lang.Integer">168</Object> </Response> <Exception/> </ServiceResponse>
我想提取“168”,但我只能提取“java.lang.Integer”
谢谢你的帮助
TBXML 有valueOfAttributeNamed用于获取属性值的textForElement方法和用于获取元素值的方法。
valueOfAttributeNamed
textForElement
所以就这样做吧。
if ([[TBXML elementName:objElement] isEqualToString:@"Object"]) { NSLog(@"%@",[TBXML textForElement:objElement]) ; }
代替
[TBXML valueOfAttributeNamed:@"type" forElement:objElement]