CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
BeautifulSoup.BeautifulSOAP Class Reference
Inheritance diagram for BeautifulSoup.BeautifulSOAP:
BeautifulSoup.BeautifulStoneSoup BeautifulSoup.Tag BeautifulSoup.PageElement BeautifulSoup.SimplifyingSOAPParser

Public Member Functions

def popTag
 
- Public Member Functions inherited from BeautifulSoup.BeautifulStoneSoup
def __getattr__
 
def __init__
 
def convert_charref
 
def endData
 
def handle_charref
 
def handle_comment
 
def handle_data
 
def handle_decl
 
def handle_entityref
 
def handle_pi
 
def isSelfClosingTag
 
def parse_declaration
 
def popTag
 
def pushTag
 
def reset
 
def unknown_endtag
 
def unknown_starttag
 
- Public Member Functions inherited from BeautifulSoup.Tag
def __call__
 
def __contains__
 
def __delitem__
 
def __eq__
 
def __getattr__
 
def __getitem__
 
def __init__
 
def __iter__
 
def __len__
 
def __ne__
 
def __nonzero__
 
def __repr__
 
def __setitem__
 
def __str__
 
def __unicode__
 
def childGenerator
 
def clear
 
def decompose
 
def fetchText
 
def find
 
def findAll
 
def firstText
 
def get
 
def getString
 
def getText
 
def has_key
 
def index
 
def prettify
 
def recursiveChildGenerator
 
def renderContents
 
def setString
 

Additional Inherited Members

- Public Attributes inherited from BeautifulSoup.BeautifulStoneSoup
 convertEntities
 
 convertHTMLEntities
 
 convertXMLEntities
 
 currentData
 
 currentTag
 
 declaredHTMLEncoding
 
 escapeUnrecognizedEntities
 
 fromEncoding
 
 hidden
 
 instanceSelfClosingTags
 
 literal
 
 markup
 
 markupMassage
 
 originalEncoding
 
 parseOnlyThese
 
 previous
 
 quoteStack
 
 smartQuotesTo
 
 tagStack
 
- Public Attributes inherited from BeautifulSoup.Tag
 attrMap
 
 attrs
 
 containsSubstitutions
 
 contents
 
 convertHTMLEntities
 
 convertXMLEntities
 
 escapeUnrecognizedEntities
 
 hidden
 
 isSelfClosing
 
 name
 
 parserClass
 
- Static Public Attributes inherited from BeautifulSoup.BeautifulStoneSoup
 ALL_ENTITIES = XHTML_ENTITIES
 
string HTML_ENTITIES = "html"
 
list MARKUP_MASSAGE
 
dictionary NESTABLE_TAGS = {}
 
list PRESERVE_WHITESPACE_TAGS = []
 
dictionary QUOTE_TAGS = {}
 
dictionary RESET_NESTING_TAGS = {}
 
string ROOT_TAG_NAME = u'[document]'
 
dictionary SELF_CLOSING_TAGS = {}
 
dictionary STRIP_ASCII_SPACES = { 9: None, 10: None, 12: None, 13: None, 32: None, }
 
string XHTML_ENTITIES = "xhtml"
 
string XML_ENTITIES = "xml"
 
- Static Public Attributes inherited from BeautifulSoup.Tag
 fetch = findAll
 
 findChild = find
 
 findChildren = findAll
 
 first = find
 
- Properties inherited from BeautifulSoup.Tag
 string = property(getString, setString)
 
 text = property(getText)
 

Detailed Description

This class will push a tag with only a single string child into
the tag's parent as an attribute. The attribute's name is the tag
name, and the value is the string child. An example should give
the flavor of the change:

<foo><bar>baz</bar></foo>
 =>
<foo bar="baz"><bar>baz</bar></foo>

You can then access fooTag['bar'] instead of fooTag.barTag.string.

This is, of course, useful for scraping structures that tend to
use subelements instead of attributes, such as SOAP messages. Note
that it modifies its input, so don't print the modified version
out.

I'm not sure how many people really want to use this class; let me
know if you do. Mainly I like the name.

Definition at line 1675 of file BeautifulSoup.py.

Member Function Documentation

def BeautifulSoup.BeautifulSOAP.popTag (   self)

Definition at line 1695 of file BeautifulSoup.py.

References BeautifulSoup.BeautifulStoneSoup.tagStack.

1696  def popTag(self):
1697  if len(self.tagStack) > 1:
1698  tag = self.tagStack[-1]
1699  parent = self.tagStack[-2]
1700  parent._getAttrMap()
1701  if (isinstance(tag, Tag) and len(tag.contents) == 1 and
1702  isinstance(tag.contents[0], NavigableString) and
1703  not parent.attrMap.has_key(tag.name)):
1704  parent[tag.name] = tag.contents[0]
1705  BeautifulStoneSoup.popTag(self)
1706 
1707 #Enterprise class names! It has come to our attention that some people
1708 #think the names of the Beautiful Soup parser classes are too silly
1709 #and "unprofessional" for use in enterprise screen-scraping. We feel
1710 #your pain! For such-minded folk, the Beautiful Soup Consortium And
1711 #All-Night Kosher Bakery recommends renaming this file to
1712 #"RobustParser.py" (or, in cases of extreme enterprisiness,
1713 #"RobustParserBeanInterface.class") and using the following
#enterprise-friendly class aliases: