--00163646d0388fc60b04a0127d2c
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Apr 1, 2011 at 9:22 PM, Kyle X. <haebooty / yahoo.com> wrote:
> Thank you Jesus, that is exactly what I was looking for and it works
> great!

Here's the same with REXML.

09:12:25 Temp$ ./rx2.rb
Approach 1
117.4
119.7
0.
Approach 2
117.4
119.7
0.
Approach 3
117.4
119.7
0.0
09:12:45 Temp$ cat -n rx2.rb
     1  #!/bin/env ruby19
     2
     3  require 'rexml/document'
     4
     5  doc  EXML::Document.new(DATA.read)
     6
     7  puts 'Approach 1'
     8
     9  REXML::XPath.each(doc, "//*[@id1671']//@ref") do |e|
    10    REXML::XPath.each(doc,
"//*[@id{e.value}']//IfcLengthMeasure/text()") do |lm|
    11      puts lm
    12    end
    13  end
    14
    15  puts 'Approach 2'
    16
    17  refs  EXML::XPath.each(doc, "//*[@id1671']//@ref").map
{|e| e.value}
    18  values  efs.map {|r| REXML::XPath.each(doc,
"//*[@id{r}']//IfcLengthMeasure/text()").to_a}.flatten
    19  puts values
    20
    21  puts 'Approach 3'
    22
    23  refs  EXML::XPath.each(doc, "//*[@id1671']//@ref").map
{|e| e.value}
    24  values  efs.map {|r| REXML::XPath.each(doc,
"//*[@id{r}']//IfcLengthMeasure/text()").map {|x|
x.value.to_f}}.flatten
    25  puts values
    26
    27  __END__
    28  <root xmlns:expttp://foo" xmlns:xsittp://bar">
    29  <IfcWallStandardCase id1677">
    30   <ObjectPlacement>
    31     <IfcLocalPlacement xsi:nilrue" ref1671"/>
    32   </ObjectPlacement>
    33  </IfcWallStandardCase>
    34
    35  <IfcAxis2Placement3D id1671">
    36   <Location>
    37     <IfcCartesianPoint xsi:nilrue" ref1667"/>
    38   </Location>
    39  </IfcAxis2Placement3D>
    40
    41  <IfcCartesianPoint id1667">
    42   <Coordinates id1670" exp:cTypeist">
    43     <IfcLengthMeasure exp:pos">117.4</IfcLengthMeasure>
    44     <IfcLengthMeasure exp:pos">119.7</IfcLengthMeasure>
    45     <IfcLengthMeasure exp:pos">0.</IfcLengthMeasure>
    46   </Coordinates>
    47  </IfcCartesianPoint>
    48  </root>
09:12:46 Temp$


Have fun!

Cheers

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

--00163646d0388fc60b04a0127d2c
Content-Type: application/x-sh; name="rx2.rb"
Content-Disposition: attachment; filename="rx2.rb"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gm32chhu0

IyEvYmluL2VudiBydWJ5MTkKCnJlcXVpcmUgJ3JleG1sL2RvY3VtZW50JwoKZG9jID0gUkVYTUw6
OkRvY3VtZW50Lm5ldyhEQVRBLnJlYWQpCgpwdXRzICdBcHByb2FjaCAxJwoKUkVYTUw6OlhQYXRo
LmVhY2goZG9jLCAiLy8qW0BpZD0naTE2NzEnXS8vQHJlZiIpIGRvIHxlfAogIFJFWE1MOjpYUGF0
aC5lYWNoKGRvYywgIi8vKltAaWQ9JyN7ZS52YWx1ZX0nXS8vSWZjTGVuZ3RoTWVhc3VyZS90ZXh0
KCkiKSBkbyB8bG18CiAgICBwdXRzIGxtCiAgZW5kCmVuZAoKcHV0cyAnQXBwcm9hY2ggMicKCnJl
ZnMgPSBSRVhNTDo6WFBhdGguZWFjaChkb2MsICIvLypbQGlkPSdpMTY3MSddLy9AcmVmIikubWFw
IHt8ZXwgZS52YWx1ZX0KdmFsdWVzID0gcmVmcy5tYXAge3xyfCBSRVhNTDo6WFBhdGguZWFjaChk
b2MsICIvLypbQGlkPScje3J9J10vL0lmY0xlbmd0aE1lYXN1cmUvdGV4dCgpIikudG9fYX0uZmxh
dHRlbgpwdXRzIHZhbHVlcwoKcHV0cyAnQXBwcm9hY2ggMycKCnJlZnMgPSBSRVhNTDo6WFBhdGgu
ZWFjaChkb2MsICIvLypbQGlkPSdpMTY3MSddLy9AcmVmIikubWFwIHt8ZXwgZS52YWx1ZX0KdmFs
dWVzID0gcmVmcy5tYXAge3xyfCBSRVhNTDo6WFBhdGguZWFjaChkb2MsICIvL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