Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2599
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | "Kyle X." <haebooty@yahoo.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: Can you search in REXML by attributes? |
| Date | Sun, 10 Apr 2011 18:01:11 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 68 |
| Message-ID | <cce24af37a85d53425022f133364bb62@ruby-forum.com> (permalink) |
| References | <6680e1dd986ba2ce87d806950a81ee57@ruby-forum.com> <BANLkTim=ZwXUL-1hoLvfDzN8EUCUQDk1Vw@mail.gmail.com> <07d88b73a8b6b59812b5fed98c782aca@ruby-forum.com> <AANLkTikDnWpKcMM70U1VjsE5QJv8kpAbkFsKLKnyijtG@mail.gmail.com> |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | Quoted-printable |
| X-Trace | talisker.lacave.net 1302476496 67529 65.111.164.187 (10 Apr 2011 23:01:36 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Sun, 10 Apr 2011 23:01:36 +0000 (UTC) |
| In-Reply-To | <AANLkTikDnWpKcMM70U1VjsE5QJv8kpAbkFsKLKnyijtG@mail.gmail.com> |
| 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 | 381264 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <cce24af37a85d53425022f133364bb62@ruby-forum.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:2599 |
Show key headers only | View raw
"Jesús Gabriel y Galán" <jgabrielygalan@gmail.com> wrote in post
#990433:
>
> I usually use Nokogiri to handle XML documents, and find css selectors
> easier than XPath. I'd do it like this:
>
> doc = Nokogiri::XML(<<END
> <root xmlns:exp="http://foo" xmlns:xsi="http://bar">
> <IfcWallStandardCase id="i1677">
> <ObjectPlacement>
> <IfcLocalPlacement xsi:nil="true" ref="i1671"/>
> </ObjectPlacement>
> </IfcWallStandardCase>
>
> <IfcAxis2Placement3D id="i1671">
> <Location>
> <IfcCartesianPoint xsi:nil="true" ref="i1667"/>
> </Location>
> </IfcAxis2Placement3D>
>
> <IfcCartesianPoint id="i1667">
> <Coordinates id="i1670" exp:cType="list">
> <IfcLengthMeasure exp:pos="0">117.4</IfcLengthMeasure>
> <IfcLengthMeasure exp:pos="1">119.7</IfcLengthMeasure>
> <IfcLengthMeasure exp:pos="2">0.</IfcLengthMeasure>
> </Coordinates>
> </IfcCartesianPoint>
> </root>
> END
> )
>
> reference = doc.css("#i1671 Location
> IfcCartesianPoint").attribute("ref").value
> doc.css("##{reference} Coordinates IfcLengthMeasure").map {|element|
> element.text}
>
> This returns: => ["117.4", "119.7", "0."]
>
Thank you for the help. I had been using REXML and it was working find
with one exception, it can be very slow. So now I am trying to use
Nokogiri, and am running into a very simple error, I cannot load xml
files. From the Nokogiri website I have been trying what is in their
tutorial:
f = File.open("blossom.xml")
doc = Nokogiri::XML(f)
f.close
But regardles of what I put in the ("...") it returns -
Error: #<Errno::EINVAL: C:/Program Files (x86)/Google/Google SketchUp
8/Plugins/examples/auto.rb:11:in `read': Invalid argument -
c:ourwalls.xml>
or
Error: #<Errno::ENOENT: C:/Program Files (x86)/Google/Google SketchUp
8/Plugins/examples/auto.rb:11:in `read': No such file or directory -
fourwalls.xml>
If I am simply trying to open an XML file named file.xml located at C:\,
what would I put to open it? I have tried many things such as f
=File.open("C:\file.xml") and what not with no luck. What do I need to
do to open this?
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-03-31 19:53 -0500
Re: Can you search in REXML by attributes? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-03-31 20:27 -0500
Re: Can you search in REXML by attributes? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-03-31 20:45 -0500
Re: Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-04-01 11:27 -0500
Re: Can you search in REXML by attributes? Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-04-01 12:19 -0500
Re: Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-04-10 18:01 -0500
Re: Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-04-10 18:27 -0500
Re: Can you search in REXML by attributes? Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-04-11 02:37 -0500
Re: Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-04-11 13:57 -0500
Re: Can you search in REXML by attributes? Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-04-12 03:17 -0500
Re: Can you search in REXML by attributes? Robert Klemme <shortcutter@googlemail.com> - 2011-04-12 04:46 -0500
Re: Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-04-12 14:39 -0500
Re: Can you search in REXML by attributes? Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-04-12 15:37 -0500
Re: Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-04-01 14:22 -0500
Re: Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-04-04 13:44 -0500
Re: Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-04-19 15:42 -0500
Re: Can you search in REXML by attributes? "Kyle X." <haebooty@yahoo.com> - 2011-04-20 02:22 -0500
csiph-web