From: John W Higgins Date: 2009-12-01T03:33:52+09:00 Subject: Re: Odd puts behaviour with REXML --001517576d90dd6e1a04799ae1e2 Content-Type: text/plain; charset=ISO-8859-1 Morning David, On Mon, Nov 30, 2009 at 10:19 AM, David Sainte-claire < dsainteclaire@gmail.com> wrote: > Hello, > > This is really weird, and I'm not sure if maybe there's a formatting > option that I can set on the puts method that will solve it. Hopefully > someone has done something similar?? > > I have been using REXML to parse through an XML document that I get back > from calling a ReST-ish web service, and up until now it has parsed > every single element as I'd expect. But I run into this small patch of > data were it acts weird. The XML looks like this: > > > > eSupport > Find related product support and help in > > > http://www.somecompany.com/US/perl/model-home.pl?XID=M:products:crmportal&LOC=3&mdl=someModel > > > > > And I'm parsing it like this: > data.elements.each("product/profile/support"){|element| > element.elements.each() do |child| > puts "Did XPATH match any profile elements?" > puts child.text > end > } > > I know it's pretty rudimentary, but I'm just confused as to why this > same pattern has been able to get text out of every other element I have > searched for, but here I get something like this when I loop through the > subelemenents: > Did XPATH match any profile elements? > ???Product_Support_Link_Title??? > Did XPATH match any profile elements? > ???Product_Support_Link_Prefix??? > Did XPATH match any profile elements? > ???Product_Support_Link???&mdl=someModel > > It looks like XPATH doesn't like the format of the text somehow, but I > have no idea what it is about it that it doesn't like since it appears > to be just normal text to me. > > Anyone have any ideas? It looks like something that REXML is doing > since it outputs the path to the element in the document Product --> > Support but I don't have a clue where the _Link is coming from? > > Rule one of anything like this is to remove each element from the XML file one by one and see which one is breaking you. In this case you will find that it's the link element because you are using ampersands in the URL. See here http://www.w3.org/TR/xhtml1/guidelines.html#C_12 John --001517576d90dd6e1a04799ae1e2--