开发者

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

开发者 https://www.devze.com 2023-03-23 13:25 出处:网络
How to get the value of the title tag? <?xml version=\"1.0\" encoding=开发者_如何转开发\"UTF-8\"?>

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

精彩评论

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