> The difference is that you have namespaces in your file. Check this URL:
>
> http://tenderlovemaking.com/2009/04/23/namespaces-in-xml/
>
> In order to make this work, you can do something like this:
>
> require 'nokogiri'
>
> doc = Nokogiri::XML(File.read("one.xml"))
> doc.collect_namespaces.each {|key,value| puts "#{key} => #{value}"}
> doc.css("uosNS|IfcCartesianPoint uosNS|Coordinates
> uosNS|IfcLengthMeasure", {"uosNS" =>
> "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL"}).each {|el| puts
> el.text}
>
> (I added a line that shows all namespaces in the document). All nodes
> under the uos node inherit the namespace referenced by the url you see
> in the code, so in order to search for nodes within the uos node, you
> need to specify the namespace.

Thank you for the response.  After reading the link you provided to make
any xml file read using Nokogiri if it has a namespace you must include
that with each time you are trying to grab information from it correct
(the name space is the url in xmlns="..." correct?)?  Like you did here:

> doc.css("uosNS|IfcCartesianPoint uosNS|Coordinates
> uosNS|IfcLengthMeasure", {"uosNS" =>
> "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL"}).each {|el| puts
> el.text}

In the link it says that, "Even though using namespaces is essential
when searching an XML document, Nokogiri tries to help out. If there are
namespaces declared on the root node of a document, Nokogiri will
automatically register those for you. You will still have to use the
prefix when searching the document, but the URL registration is done for
you."

Making both -
1  doc.xpath('//xmlns:tire',
2    'xmlns' => 'http://alicesautosupply.example.com/'
3  )
4  doc.xpath('//xmlns:tire')
Equal.

I tried this using the .xml I posted and it does not work.  Is this
because the xmlns is not in the first line immediately following <?xml
version="1.0"?>?  In turn making it necessary for every inquirary to
include {"uosNS" => "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL"}?

>I will have to read the whole file but it may make a crucial
>difference whether it does so in one go or in chunks.  Large files
>might not even be readable with the File.read approach.  If you pass
>the file as a single string there is no choice but if you pass the
>File instance nokogiri can decide what to do.  This is more efficient.
> Note also that because of buffering small files will have just one
>(or a few) IO operations anyway.

I will try both and see how each performs against each other and if both
work properly.

Thank you both for your replies.  Your help with this has been
invaluable.

Sincerely,
Kyle

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