Received: by 10.66.74.197 with SMTP id w5mr1726966pav.1.1343052109126; Mon, 23 Jul 2012 07:01:49 -0700 (PDT) X-BeenThere: beautifulsoup@googlegroups.com Received: by 10.68.229.8 with SMTP id sm8ls10312914pbc.0.gmail; Mon, 23 Jul 2012 07:01:47 -0700 (PDT) Received: by 10.66.85.162 with SMTP id i2mr1126922paz.30.1343052107865; Mon, 23 Jul 2012 07:01:47 -0700 (PDT) Received: by 10.66.85.162 with SMTP id i2mr1126921paz.30.1343052107856; Mon, 23 Jul 2012 07:01:47 -0700 (PDT) Return-Path: Received: from mail-pb0-f47.google.com (mail-pb0-f47.google.com [209.85.160.47]) by gmr-mx.google.com with ESMTPS id vj10si570823pbc.0.2012.07.23.07.01.47 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Jul 2012 07:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of leonard.richard...@gmail.com designates 209.85.160.47 as permitted sender) client-ip=209.85.160.47; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of leonard.richard...@gmail.com designates 209.85.160.47 as permitted sender) smtp.mail=leonard.richard...@gmail.com; dkim=pass header...@gmail.com Received: by pbbrq2 with SMTP id rq2so9735127pbb.6 for ; Mon, 23 Jul 2012 07:01:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=rRBqAO49jjVgCnVATCI1lUSgqjdIojayr5GRM/sn0Lw=; b=ep2A9186sGHSd2cz153Z8NRGxzti8LShC6iKFj4Pdd1f0zBlJ08p2ielKRGL9ccoux rCKbOWc4o6mk2s1HWh8hmikZ4wtAXuE5XaKpd1R3xmrP11H0fkkJTB6lGVk4BqKcjWdj zy9w9/zphiArQ9p8q9EFKLvrb1RfOhMsa9+f/+WRtPl6Iz6Ncz1/4rtAuB8vojgFESiN /kMDlmC8qMyetG0yAw7hmdKraAMD6YOcVi1p+7yGcMon8/Jo1qyKC79jC5Qmt9IQRc0J epcM9RysPM5Gt/vb00RTlxkGfi9uShKAsTEb9NZEV6QXYEpAuUApZ0J1lEIhl4o5wIOX Lq9A== MIME-Version: 1.0 Received: by 10.68.132.103 with SMTP id ot7mr35327988pbb.79.1343052107748; Mon, 23 Jul 2012 07:01:47 -0700 (PDT) Sender: leonard.richard...@gmail.com Received: by 10.142.207.15 with HTTP; Mon, 23 Jul 2012 07:01:47 -0700 (PDT) In-Reply-To: References: Date: Mon, 23 Jul 2012 10:01:47 -0400 Message-ID: Subject: Re: How to parse a tag named 'name'? From: Leonard Richardson To: beautifulsoup@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 > I don't know if this is the right place to ask for help. If it isn't I > apologize. > > I have this xml, > > > a simple text > some/path > ...... > > and this is my code > > for project in self.soup.find_all("project"): > projectPath = project.path.string.split('/') > print projectPath[0] #is ok > print project.name.string# error AttributeError: 'str' > object has no attribute 'string' > > I can't parse the tag named 'name'. I have tried the rest of them and they > work. > Is this relevant with the fact that bs provided already the name attribute? Yes. In your example, `project.name` is the string "project". To find a tag called , use the find() method: project.find("name") http://www.crummy.com/software/BeautifulSoup/bs4/doc/#find Leonard