I actually just modified my stuff to parse out the CDATA stuff, but using sed instead.<div><br></div><div>You might try: vm=`onevm show #{VMID} -x | <span class="Apple-style-span" style="font-family: Helvetica; font-size: 12px; "> sed -e 's/<\!\[CDATA\[//g' -e 's/\]\]>//g'`</span></div>
<div><font class="Apple-style-span" face="Helvetica"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: 12px; ">--Frank</span></div>
<div>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.35">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
</style>
<br><div class="gmail_quote">On Tue, Nov 30, 2010 at 4:07 PM, Shi Jin <span dir="ltr"><<a href="mailto:jinzishuai@yahoo.com">jinzishuai@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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>
</blockquote></div><br><br clear="all"><br>-- <br>--Frank<br>
</div>