Parses the element and subelements and parses any HTML enabled text to
        its original HTML form for rendering.

        :returns: Parsed HTML enabled text content.
        :rtype: str
67
def get_html_content(self):
        

        # Extract full element node content (including subelements)
        html_content = ''
        if hasattr(self, 'xml_element'):
            xml = self.xml_element
            content_list = ["" if xml.text is None else xml.text]

            def to_string(xml):
                if isinstance(xml, _Comment):
                    return str(xml)
                else:
                    return ElementTree.tostring(xml).decode('utf-8')

            content_list += [to_string(e) for e in xml.getchildren()]

            full_xml_content = "".join(content_list)

            # Parse tags to generate HTML valid content
            first_regex = r'html:'
            second_regex = r' xmlns:html=(["\'])(?:(?=(\\?))\2.)*?\1'
            html_content = re.sub(first_regex, '',
                                  re.sub(second_regex, '', full_xml_content))

        return html_content
556463
def raw_html(self) -> _RawHTML:
        
        if self._html:
            return self._html
        else:
            return etree.tostring(self.element, encoding='unicode').strip().encode(self.encoding)
1246159
def _parse_template(self, element):
        
        # If the response element has no tags, just store the raw text as the only response
        if not len(element):
            self._response = (newlines_to_spaces(element.text),)
            self._log.info('Assigning text only response')
            return

        # Otherwise, parse the tags now
        self._response = tuple(self.agentml.parse_tags(element, self.trigger))
483211
def _buildElementTree(self,):
        

        t_paging = ctree.Element('paging')
        t_paging.set('model', self.model)
        for key in self.__dict__.keys():
            if key != 'model':
                t_tag = ctree.SubElement(t_paging, key)
                for item in self.__dict__[key].items():
                    t_tag.set(*item)

        self.etree = t_paging
        return  t_paging
23494
def _parse_text(self, el, refs=None, specials=None,  element_cls=Paragraph):
        """"""
        if specials is None:
            specials = {}
        if refs is None:
            refs = {}
        elements = self._parse_element_r(el, specials=specials, refs=refs, element_cls=element_cls)
        # This occurs if the input element is self-closing... (some table td in NLM XML)
        if not elements:
            return [element_cls('')]
        element = elements[0]
        for next_element in elements[1:]:
            element += element_cls(' ') + next_element
        return [element]
414552
def parse(self, xml_str):
        # type: (str) -> List[EndpointDescription]
        
        # Parse the document
        root = ElementTree.fromstring(xml_str)
        if root.tag != TAG_ENDPOINT_DESCRIPTIONS:
            raise ValueError("Not an EDEF XML: {0}".format(root.tag))

        # Parse content
        return [
            self._parse_description(node)
            for node in root.findall(TAG_ENDPOINT_DESCRIPTION)
        ]
155095
def texts(element)
        texts = []
        child_nodes = element.child_nodes
        (0...child_nodes.length).each do |i|
          item = child_nodes.item(i)
          if item.node_type == Node.TEXT_NODE
            texts << item.get_data
          end
        end
        texts
      end
1227249
def parse(self, xmltext):
        
        
        xml = LEMSXMLNode(xe.XML(xmltext))

        if xml.ltag != 'lems' and xml.ltag != 'neuroml':
            raise ParseError('<Lems> expected as root element (or even <neuroml>), found: {0}'.format(xml.ltag))
        '''
        if xml.ltag == 'lems':
            if 'description' in xml.lattrib:
                self.description = xml.lattrib['description']
        '''

        self.process_nested_tags(xml)
192798
def parse(self, element):
        """"""
        #All the children of this element are what we are trying to parse.
        result = []
        for child in element:
            if child.tag in self.lines:
                values = { child.tag: self.lines[child.tag].parse(child) }
                result.append(values)

        return result
318353
def lxml(self) -> _LXML:
        
        if self._lxml is None:
            self._lxml = etree.fromstring(self.raw_xml)

        return self._lxml
293355
def parse(text, elements, fallback):
    
    # this is a raw list of elements that may contain overlaps.
    tokens = []
    for etype in elements:
        for match in etype.find(text):
            tokens.append(Token(etype, match, text, fallback))
    tokens.sort()
    tokens = _resolve_overlap(tokens)
    return make_elements(tokens, text, fallback=fallback)
1079898
def convert_html_to_xml(self):
        

        if hasattr(self, 'content') and self.content != '':
            regex = r'<(?!/)(?!!)'
            xml_content = re.sub(regex, '<xhtml:', self.content)
            return xml_content
        else:
            return ''
861370
def to_xml(self):
        
        root = ET.Element("scheme")

        ET.SubElement(root, "title").text = self.title

        # add a description subelement if it's defined
        if self.description is not None:
            ET.SubElement(root, "description").text = self.description

        # add all other subelements to this Scheme, represented by (tag, text)
        subelements = [
            ("use_external_validation", self.use_external_validation),
            ("use_single_instance", self.use_single_instance),
            ("streaming_mode", self.streaming_mode)
        ]
        for name, value in subelements:
            ET.SubElement(root, name).text = str(value).lower()

        endpoint = ET.SubElement(root, "endpoint")

        args = ET.SubElement(endpoint, "args")

        # add arguments as subelements to the <args> element
        for arg in self.arguments:
            arg.add_to_document(args)

        return root
224545
def get_element(parent_to_parse, element_path=None):
    

    if parent_to_parse is None:
        return None

    elif isinstance(parent_to_parse, ElementTree):
        parent_to_parse = parent_to_parse.getroot()

    elif hasattr(parent_to_parse, 'read'):
        parent_to_parse = string_to_element(parent_to_parse.read())

    elif isinstance(parent_to_parse, STRING_TYPES):
        parent_to_parse = string_to_element(parent_to_parse)

    elif isinstance(parent_to_parse, dict):
        parent_to_parse = dict_to_element(parent_to_parse)

    if parent_to_parse is None:
        return None
    elif not isinstance(parent_to_parse, ElementType):
        element_type = type(parent_to_parse).__name__
        raise TypeError('Invalid element type: {0}'.format(element_type))

    return parent_to_parse.find(element_path) if element_path else parent_to_parse
1219943
def _parse(self):
        
        for child in self._element:
            method_name = '_parse_{0}'.format(str(child.tag))  # TODO: This is a hack, skip comment objects here

            if hasattr(self, method_name):
                parse = getattr(self, method_name)
                parse(child)
1014595
def _parse_html(self):
        

        if self.config.parser != 'lxml':
            raise NotImplementedError('%s parser not implemented' %
                                      self.config.parser)

        self.parser = etree.HTMLParser()

        try:
            self.parsed_tree = etree.parse(StringIO(self.html), self.parser)

        except ValueError, e:
            if u'Unicode strings with encoding declaration are not supported' \
                    in unicode(e):

                # For some reason, the HTML/XML declares another encoding
                # in its meta tags. TODO: we should probably remove this
                # meta tag, because the sparks detection mechanism usually
                # does a pretty good job at finding it.
                #
                # For now, this will fail for anything other than utf-8 and
                # make the program crash.
                self.parsed_tree = etree.parse(StringIO(
                    self.html.encode('utf-8')), self.parser)
732796
def _to_DOM(self):
        
        root_node = ET.Element("ozone")
        reference_time_node = ET.SubElement(root_node, "reference_time")
        reference_time_node.text = str(self._reference_time)
        reception_time_node = ET.SubElement(root_node, "reception_time")
        reception_time_node.text = str(self._reception_time)
        interval_node = ET.SubElement(root_node, "interval")
        interval_node.text = str(self._interval)
        value_node = ET.SubElement(root_node, "value")
        value_node.text = str(self.du_value)
        root_node.append(self._location._to_DOM())
        return root_node