Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3190
| From | "Kyle X." <haebooty@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: Can you search in REXML by attributes? |
| Date | 2011-04-19 15:42 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <6d4391bb004fa8211df86ec6e6babf82@ruby-forum.com> (permalink) |
| References | <6680e1dd986ba2ce87d806950a81ee57@ruby-forum.com> |
Hello, Nokogiri has been going well for me but recently I have been
having trouble trying to read some xml, and from my reading online I
cannot find the proper way to write it using Nokogiri. Here are the two
lines I am having trouble with:
1)
<IfcWallStandardCase id="i17855">
<Representation>
<IfcProductDefinitionShape id="i17925">
<Representations id="i17928" exp:cType="list">
<IfcShapeRepresentation exp:pos="0" xsi:nil="true"
ref="i17886"/>
<IfcShapeRepresentation exp:pos="1" xsi:nil="true"
ref="i17919"/>
</Representations>
</IfcProductDefinitionShape>
</Representation>
</IfcWallStandardCase>
I am trying to get the reference for exp:pos="1", and I had this working
with using REXML with the following -
XPath.match( $doc, "//IfcWallStandardCase//*[@pos='1']" )
With nokogiri I can get it to read both pos 0 and 1, using .css and
xpath-
$doc_noko.css("uosNS|IfcWallStandardCase uosNS|IfcShapeRepresentation",
{"uosNS" => $http})
and
$doc_noko.xpath("//uosNS:IfcWallStandardCase//uosNS:IfcShapeRepresentation",
{"uosNS" => $http})
But cannot figure out how to get it to read only pos=1 using either
method and continuously get error or nil.
2)
<IfcDirection id="i1574">
<DirectionRatios id="i1577" exp:cType="list">
<exp:double-wrapper pos="0">1.</exp:double-wrapper>
<exp:double-wrapper pos="1">0.</exp:double-wrapper>
<exp:double-wrapper pos="2">0.</exp:double-wrapper>
</DirectionRatios>
</IfcDirection>
The issue I am having here is that I am reading this with Nokogiri using
xpath and the colon in exp:double is giving me trouble since the xpath
is written -
ref = "i1574"
$doc_noko.xpath("//uosNS:*[@id='#{ref}']//uosNS:exp:double-wrapper",
{"uosNS" => $http}).map {|element| element.text}
I am guessing that it would be easier to use .css here rather than
xpath. So I have tried using it but cannot seem to get it correct.
Trying -
ref = "i1574"
$doc_noko.css("uosNS|#{ref} uosNS|exp:double-wrapper", {"uosNS" =>
$http}).map {|element| element.text}
As I read in a previous post that you call the ref using #{} for css,
but this returns nil for me.
Any ideas?
--
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