Really? I am confused.<div>Can you run the following code and see if your output is the same as mine?</div><div><div>[cloudadmin@rhel6-one2 cgroups]$ cat test </div><div>#!/usr/bin/ruby</div><div>require 'rexml/document'</div>
<div>vmcdata=<<XML</div><div><CPU></div><div> <![CDATA[2]]></div><div></CPU></div><div>XML</div><div><br></div><div>doc=REXML::Document.new(vmcdata).root</div><div>puts doc</div><div>puts doc.text</div>
<div><br></div><div>vmold=<<XML</div><div><CPU></div><div>2</div><div></CPU></div><div>XML</div><div><br></div><div>docold=REXML::Document.new(vmold).root</div><div>puts docold</div><div>puts docold.text</div>
<div>[cloudadmin@rhel6-one2 cgroups]$ ./test </div><div><CPU></div><div> <![CDATA[2]]></div><div></CPU></div><div><br></div><div> </div><div><CPU></div><div>2</div><div></CPU></div><div><br>
</div><div>2</div></div><div><div>[cloudadmin@rhel6-one2 cgroups]$ ruby --version</div><div>ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux]</div></div><div><br></div><div><br></div><div>Thanks.</div><div><br></div><div>
Shi</div><div><br><div class="gmail_quote">On Tue, Nov 30, 2010 at 5:18 PM, hector <span dir="ltr"><<a href="mailto:hector@convivencial.org">hector@convivencial.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
CDATA labels are ignored by REXML so you shouldn't worry about them.<br>
It's like they're not there.<br>
<br>
Im testing your example and it simply works. Perhaps you can give some<br>
more input on the problem? As I say, it shoudln't be CDATA related if<br>
working with REXML.<br>
<br>
Héctor<br>
<br>
<br>
El 01/12/10 01:07, Shi Jin escribió:<br>
<div><div></div><div class="h5">> Hi there,<br>
><br>
> I used to have some ruby script to parse the output of "onevm show <vmid> -x". After switching from 1.4 to 2.0, they no longer work. I think the problem is that now the output of the XML has lots of CDATA in it. For example<br>
> <CPU><![CDATA[2]]></CPU><br>
> which used to be just<br>
> <CPU><2></CPU><br>
><br>
> I am not a Ruby expert. Is there any easy way to parse the XML in Ruby to get the CDATA data? My code looks like<br>
> def getCPU<br>
> vm=`onevm show #{VMID} -x`<br>
> doc=REXML::Document.new(vm).root<br>
> $cpu=doc.elements['/VM/TEMPLATE/CPU'].text.strip<br>
> end<br>
><br>
> Thanks a lot.<br>
><br>
> Shi<br>
><br>
> --<br>
> Shi Jin, PhD<br>
><br>
><br>
><br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br>
> <a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
><br>
<br>
<br>
</div></div>--<br>
<font color="#888888">Hector<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Shi Jin, Ph.D.<br><br>
</div>