Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail From: "Kyle X." Newsgroups: comp.lang.ruby Subject: Re: Can you search in REXML by attributes? Date: Sun, 10 Apr 2011 18:27:45 -0500 Organization: Service de news de lacave.net Lines: 58 Message-ID: <560f26c9f7549339ef393be5559307fd@ruby-forum.com> References: <6680e1dd986ba2ce87d806950a81ee57@ruby-forum.com> <07d88b73a8b6b59812b5fed98c782aca@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: Quoted-printable X-Trace: talisker.lacave.net 1302478086 70494 65.111.164.187 (10 Apr 2011 23:28:06 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Sun, 10 Apr 2011 23:28:06 +0000 (UTC) In-Reply-To: X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 381265 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <560f26c9f7549339ef393be5559307fd@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:2600 Kyle X. wrote in post #992033: > "Jes=C3=BAs Gabriel y Gal=C3=A1n" wrote in p= ost > #990433: >> >> I usually use Nokogiri to handle XML documents, and find css selectors= >> easier than XPath. I'd do it like this: >> >> doc =3D Nokogiri::XML(<> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> 117.4 >> 119.7 >> 0. >> >> >> >> END >> ) >> >> reference =3D doc.css("#i1671 Location >> IfcCartesianPoint").attribute("ref").value >> doc.css("##{reference} Coordinates IfcLengthMeasure").map {|element| >> element.text} >> >> This returns: =3D> ["117.4", "119.7", "0."] Please disregard the previous post. I figured out how to load the files, but it does not appear to be reading correctly. Using- fname =3D File.open("C:/Users/Kyle/Desktop/CSUF/Research Winter 11/IFXCML/automation trials/one.xml") $doc =3D Nokogiri::XML(fname) reference =3D $doc.css(" IfcCartesianPoint Coordinates IfcLengthMeasure").first This produce and output of nil when it should be "117.4" correct? What is going wrong here? -- = Posted via http://www.ruby-forum.com/.=