Best XML Parser & advice

Hey all,

I have identified a file, which is not an XML file however its content
represents XML e.g.

127024240930

I have clearly identified in this file where the the tags are however I
have a few issues to overcome.

First, each character is delimited by a null character - this is not a
problem I am I have found a solution to remove the null characters thus
giving text similar to that above. I am not struggling how I get from an
array containing the above data with null characters removed to parsing
the XML?

What does everyone suggest as to the best XML library and the best way
to parse the data as it stands in an array instead of an XML file.

Many thanks

On Wed, 11 Aug 2010 04:59:09 +0900, Stuart C. wrote:

First, each character is delimited by a null character - this is not a
problem I am I have found a solution to remove the null characters thus
giving text similar to that above. I am not struggling how I get from an
array containing the above data with null characters removed to parsing
the XML?

Isn’t that form of delimiting more commonly called UTF-16 (which
happens also to be a valid XML encoding …)?

-jh

Ok, not to familIar with encoding, so thanks for that.

Would you suggest rexml, e.g.

xmlData.elements.each(“userdata/time”){
|e| puts "Time : " + e.attributes[“time”]
}

Thanks
Jonathan H. wrote:

On Wed, 11 Aug 2010 04:59:09 +0900, Stuart C. wrote:

First, each character is delimited by a null character - this is not a
problem I am I have found a solution to remove the null characters thus
giving text similar to that above. I am not struggling how I get from an
array containing the above data with null characters removed to parsing
the XML?

Isn’t that form of delimiting more commonly called UTF-16 (which
happens also to be a valid XML encoding …)?

-jh

On Tue, Aug 10, 2010 at 4:34 PM, Stuart C.
[email protected] wrote:

xmlData.elements.each(“userdata/time”){
|e| puts "Time : " + e.attributes[“time”]
}

Here’s a quick example using REXML on the sample string you provided:

/tmp> cat x.rb
s =
“127024240930”

require ‘rexml/document’

REXML::Document.new(s).root.each_element(“/UserData/Time”){|e|
puts "Time: " + e.text
}

/tmp> ruby x.rb
Time: 1270242409

Thanks for this.

unknown wrote:

On Tue, Aug 10, 2010 at 4:34 PM, Stuart C.
[email protected] wrote:

xmlData.elements.each(“userdata/time”){
� |e| puts "Time : " + e.attributes[“time”]
}

Here’s a quick example using REXML on the sample string you provided: