On Fri, Aug 13, 2010 at 2:15 PM, Gary Winklosky <li...@ruby-forum.com> wrote:
>
> One way would be to check the children until you get the CData node:
>
>
> parent_node = xml_request_doc.xpath("//attached_document")
>
> # this assumes parent_node is not nil
> cdata_node = parent_node.children.detect {|n| n.cdata?}

Thanks Gary, I had been trying the .children, and tried what you
suggested to be sure, and I get nil as the return value for
cdata_node = parent_node.children.detect {|n| n.cdata?}

It is very strange - the following is the xml in text before creating
the Nokogiri doc, and it says <ATTACHED_DOCUMENT> has no children, and
does not seem to be any other objects inside the attached_document
node in the Nokogiri doc:

 <USER_INFO login=\"aaa\" password=\"bbb\" />
<REQUEST request_type=\"NEW\">
<SUPPLEMENT_ORDER_DETAIL           report_id=\"ccc\"
ordered_by=\"ddd\"           phone=\"eee\"           email=\"fff\"
      faxed_docs=\"ggg\"           rush=\"T\"
reason=\"hhh\">
    <TRADE_SUPPLEMENT account_number=\"iii\"  creditor=\"jjj\"
included_bankruptcy=\"T\">
      <ATTACHED_DOCUMENT>    <![CDATA[zzz]]>      </ATTACHED_DOCUMENT>
   </TRADE_SUPPLEMENT>
</SUPPLEMENT_ORDER_DETAIL>
</REQUEST>"

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to