nokogiri and xml preprocessing instructions

21 views
Skip to first unread message

Max Zloy

unread,
Feb 18, 2015, 8:58:38 AM2/18/15
to nokogi...@googlegroups.com
Hello!
What is the "official" way to find out if the document I am working on has a PI instruction like this: "<?xml version=.., encoding=..?>" ?
Using "doc.xpath('//processing-instruction()')" does not provide any valuable information.

Mike Dalessio

unread,
Apr 28, 2015, 6:52:02 PM4/28/15
to nokogiri-talk
Hi Max,

Thanks for asking this question. There's no "official" way, but this works (at least on MRI with libxml2) ...


You can then examine `doc.root.previous`. If it's present, it should be a PI.

HTH,
-mike


--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nokogiri-tal...@googlegroups.com.
To post to this group, send email to nokogi...@googlegroups.com.
Visit this group at http://groups.google.com/group/nokogiri-talk.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages