On Thu, Feb 23, 2012 at 5:28 AM, TwistedSkies <david.vic...@talbotuw.com> wrote: > Hi Guys, > > I am relatively new to R and was wondering if I could next my gsub command > in identifying one object > > I have data which looks like this: <name>Taiwan_250km</name> > I want it to look like this: Taiwan_250km > > So essentially I just want to gsub '<name>' and </name> with nothing! > > So far I have got this: PolyNam <- > unlist(strsplit(gsub("</name>","",PolyRaw[PolyLin],fixed = TRUE)," ")) > > Which removes the end tag, just wondering how I can nest 2 gsubs to remove > both?!
Just remove < followed by zero or more of anything except > followed by > gsub("<[^>]*>", "", "<name>Taiwan_250km</name>") or using the XML package: library(XML) xmlValue(xmlRoot(xmlTreeParse("<name>Taiwan_250km</name>", asText = TRUE))) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.