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


Groups > comp.lang.ruby > #2075

Can you search in REXML by attributes?

From "Kyle X." <haebooty@yahoo.com>
Newsgroups comp.lang.ruby
Subject Can you search in REXML by attributes?
Date 2011-03-31 19:53 -0500
Organization Service de news de lacave.net
Message-ID <6680e1dd986ba2ce87d806950a81ee57@ruby-forum.com> (permalink)

Show all headers | View raw


Hello and thank you to all the wonderful and helpful people at this
forum.  I am trying to figure out how to search through an XML file and
grab information.  I have been reading the REXML tutorials but could not
see an answer to my problem in them
(http://www.germane-software.com/software/rexml/docs/tutorial.html).
The problem is I need to search by an attribute (in this case the ref)
and cannot figure out how.  Here is a snippet of the XML I am trying to
extract information from:

<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>

So basically I have to start with IfcWallStandardCase and from there
work my way through the "ref"'s until I get to the 3 IfcLengthMeasures.
I know how to grab the first ref "i1671" using:
 XPath.match(doc,"/IfcWallStandardCase/ObjectPlacement/IfcLocalPlacement")
and some additional code.

My problem is I cannot figure out how to use this "i1671" to search the
xml and grab the next ref.  This ref is the only thing linking the items
together, so it is the only thing that I can use.

Is it possible to search a document by using an attribute, and if so
how? In this case to use the ref, "i1671" to search the document for
where it is used as id="i1671" so I can grab the next ref from there and
so on.  Any help would be greatly appreciated.

Thank you all.

Sincerely,
Kyle

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextNext 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