[one-users] ONE-2.0 CDATA in XML output

Frank Stutz frank at franksplace.net
Tue Nov 30 16:11:05 PST 2010


I actually just modified my stuff to parse out the CDATA stuff, but using
sed instead.

You might try: vm=`onevm show #{VMID} -x |  sed -e 's/<\!\[CDATA\[//g' -e
's/\]\]>//g'`

--Frank

On Tue, Nov 30, 2010 at 4:07 PM, Shi Jin <jinzishuai at yahoo.com> wrote:

> Hi there,
>
> 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
>    <CPU><![CDATA[2]]></CPU>
> which used to be just
>  <CPU><2></CPU>
>
> 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
> def getCPU
>                vm=`onevm show  #{VMID} -x`
>                doc=REXML::Document.new(vm).root
>                $cpu=doc.elements['/VM/TEMPLATE/CPU'].text.strip
> end
>
> Thanks a lot.
>
> Shi
>
> --
> Shi Jin, PhD
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>



-- 
--Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20101130/2216d168/attachment.htm>


More information about the Users mailing list