<?xml version="1.0"?> <row> <column>Business Strategy</column> <column>aaaa</column> <column>aaaaa</column> <column>gggg</column> </row> <?xml version="1.0"?> <row> <column>Company Description</column> <column>bbbb</column> <column>bbbb</column> <column>fhghj</column> </row> <?xml version="1.0"?> <row> <column>Business Strategy</column> <column>aaaa</column> <column>aaaaa</column> <column>gggg</column> </row> <?xml version="1.0"?> <row> <column>Company Description</column> <column>bbbb</column> <column>bbbb</column> <column>fhghj</column> </row> Consider the above XML. Is there anyway to remove "<?xml version="1.0"?>" and also the duplicate block with same data. For example consider the following identical blocks <?xml version="1.0"?> <row> <column>Business Strategy</column> <column>aaaa</column> <column>aaaaa</column> <column>gggg</column> </row> <?xml version="1.0"?> <row> <column>Business Strategy</column> <column>aaaa</column> <column>aaaaa</column> <column>gggg</column> </row> The resulting xml should remove the duplicate block and should contain only one. Any help would be appreciated. Thanks in Advance Anandh Anandh Kumar wrote: > Thanks mike. The solution solved my problem to a greater extent but with > one issue. > > > In the resulting solution which is as follows > > > > <root> > <row> > <column>Business Strategy</column> > <column>bus1</column> > <column>bus2</column> > <column>bus3</column> > </row> > <row> > <column>Company Description</column> > <column>tar1</column> > <column>tar2</column> > <column>tar3</column> > </row> > </root> > > > Can you suggest me how can i avoid "<?xml version="1.0"?>". > > If i give some thing like this > > puts new_doc.to_xml(:dasherize => false, :skip_instruct=>true) > > Ruby compiler threw argument error. > > Any help would be appreciated. > > > Thanks > > Anandh > > > Mike Dalessio wrote: >> Hi Anandh, >> >> I've cross-posted my reply to nokogiri-talk, which is where followup >> questions are probably best sent. >> >> On Tue, Jan 12, 2010 at 6:44 AM, Anandh Kumar >> <anandhthiyagarajan / gmail.com>wrote: >> >>> <row> >>> </row> >>> >>> <column>tar3</column> >>> </row> >>> >>> Any help would be greatly appreciated. >>> >>> >>> >> This is straightforward if you know some XPath (see >> http://www.w3.org/TR/xpath) and Nokogiri. >> >> I've posted a solution at: >> >> http://gist.github.com/275209 >> >> The general idea is that we find the nodes we care about, and then build >> a >> new document with those contents. >> >> Cheers, >> -mike -- Posted via http://www.ruby-forum.com/.