다음 XML에서 "작성자"및 "사실"태그를 구문 분석하는 방법을 알 수 없습니다. XML 문서에 서식이 이상한 here is a link으로 보이는 경우 Nokogiri로 XML 구문 분석
<response stat="ok">
−<ltml version="1.1">
−<item id="5403381" type="work">
<author id="21" authorcode="rowlingjk">J. K. Rowling</author>
<url>http://www.librarything.com/work/5403381</url>
−<commonknowledge>
−<fieldList>
−<field type="42" name="alternativetitles" displayName="Alternate titles">
−<versionList>
−<version id="3413291" archived="0" lang="eng">
<date timestamp="1298398701">Tue, 22 Feb 2011 13:18:21 -0500</date>
−<person id="18138">
<name>ablachly</name>
<url>http://www.librarything.com/profile/ablachly</url>
</person>
−<factList>
<fact>Harry Potter and the Sorcerer's Stone </fact>
</factList>
</version>
</versionList>
</field>
은 지금까지 나는 저자를 얻기 위해이 코드를 시도했지만 작동하지 않습니다 :
@xml_doc = Nokogiri::XML(open("http://www.librarything.com/services/rest/1.1/?method=librarything.ck.getwork&isbn=0590353403&apikey=d231aa37c9b4f5d304a60a3d0ad1dad4"))
@xml_doc.xpath('//response').each do |n|
@author = n
end
감사합니다. 마이클, 잘 했어. – Bryan
괜찮습니다. 내 대답이 문제를 해결 한 경우 옆에있는 체크 표시를 클릭하여 문제를 "수락 됨"으로 표시 할 수 있습니다. – michaelmichael