Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3190

Re: Can you search in REXML by attributes?

X-FeedAbuse http://nntpfeed.proxad.net/abuse.pl feeded by 88.191.16.109
Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!nospam.fr.eu.org!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 Tue, 19 Apr 2011 15:42:12 -0500
Organization Service de news de lacave.net
Lines 70
Message-ID <6d4391bb004fa8211df86ec6e6babf82@ruby-forum.com> (permalink)
References <6680e1dd986ba2ce87d806950a81ee57@ruby-forum.com>
NNTP-Posting-Host bristol.highgroove.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace talisker.lacave.net 1303245751 75844 65.111.164.187 (19 Apr 2011 20:42:31 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Tue, 19 Apr 2011 20:42:31 +0000 (UTC)
In-Reply-To <6680e1dd986ba2ce87d806950a81ee57@ruby-forum.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 381873
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <6d4391bb004fa8211df86ec6e6babf82@ruby-forum.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:3190

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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