开发者

How can I get the value from the XML content below?

How to get the value of the title tag?

<?xml version="1.0" encoding=开发者_如何转开发"UTF-8"?>
<response status="ok" permission_level="admin" message="ready to use" cached="0">
<title>johndoe</title>
</response>


If the XML is in xml then:

doc = Nokogiri::XML(xml)
jd  = doc.at('title').text

The CSS style at is probably the easiest approach for something like this. You could also use XPath if you prefer:

jd = doc.xpath('.//title').text
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜