Returns list of paragraphs in an NLM XML.

    Parameters
    ----------
    xml_string : str
        String containing valid NLM XML.

    Returns
    -------
    list of str
        List of extracted paragraphs in an NLM XML
167138
def extract_paragraphs(xml_string):
    
    tree = etree.fromstring(xml_string.encode('utf-8'))

    paragraphs = []
    # In NLM xml, all plaintext is within <p> tags, and is the only thing
    # that can be contained in <p> tags. To handle to possibility of namespaces
    # uses regex to search for tags either of the form 'p' or '{<namespace>}p'
    for element in tree.iter():
        if isinstance(element.tag, basestring) and \
           re.search('(^|})[p|title]$', element.tag) and element.text:
            paragraph = ' '.join(element.itertext())
            paragraphs.append(paragraph)
    return paragraphs
133140
def listGetRawString(self, doc, inLine):
        
        if doc is None: doc__o = None
        else: doc__o = doc._o
        ret = libxml2mod.xmlNodeListGetRawString(doc__o, self._o, inLine)
        return ret
155573
def get_xml_children(source, path):
  
  if isinstance(path, (tuple, list)):
    return source.findall(*path)
  else:
    return source.findall(path)
833171
def import_description(text):
    
    xml = ''
    is_in_ul = False
    for line in text.split('\n'):

        # don't include whitespace
        line = line.strip()
        if len(line) == 0:
            continue

        # detected as a list element?
        line_li = _import_description_to_list_element(line)
        if line_li:
            # first list element
            if not is_in_ul:
                xml += '<ul>\n'
                is_in_ul = True
            xml += '<li>' + _import_description_sentence_case(line_li) + '</li>\n'
            continue

        # done with the list
        if is_in_ul:
            xml += '</ul>\n'
            is_in_ul = False

        # regular paragraph
        xml += '<p>' + _import_description_sentence_case(line) + '</p>\n'

    # no trailing paragraph
    if is_in_ul:
        xml += '</ul>\n'

    return xml
764463
def from_string(cls, jss, xml_string):
        
        root = ElementTree.fromstring(xml_string.encode('utf-8'))
        return cls(jss, root)
709892
def to_xml_string(str = '')
      str << '<c:tx>'
      str << '<c:strRef>'
      str << ('<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>')
      str << '<c:strCache>'
      str << '<c:ptCount val="1"/>'
      str << '<c:pt idx="0">'
      str << ('<c:v>' << @text << '</c:v>')
      str << '</c:pt>'
      str << '</c:strCache>'
      str << '</c:strRef>'
      str << '</c:tx>'
    end
1214084
def nested_list_from_xml_string(xml, container_element_name, list_element_name = default_list_element_name)
        xml_doc = Nokogiri::XML(xml)
        nested_list_from_xml_doc(xml_doc.at_xpath("./#{container_element_name}"), list_element_name)
      end
578270
def get_element_by_xpath(self, xpath_str, namespaces=None):
        
        try:
            return self._root_el.findall('.' + xpath_str, namespaces)
        except (ValueError, xml.etree.ElementTree.ParseError) as e:
            raise SimpleXMLWrapperException(
                'XPath select raised exception. xpath_str="{}" error="{}"'.format(
                    xpath_str, str(e)
                )
            )
350336
public static function xmlToObject($xml_string)
    {
        if (empty($xml_string)) {
            return null;
        }

        libxml_use_internal_errors(true);
        try {
            if (false === $xml = simplexml_load_string($xml_string)) {
                throw new \Exception("Invalid XML Data: ");
            }
            // check for namespace
            $namespaces = $xml->getNamespaces();
            if (0 === $xml->count() && !empty($namespaces)) {
                $perNamespace = [];
                foreach ($namespaces as $prefix => $uri) {
                    if (false === $nsXml = simplexml_load_string($xml_string, null, 0, $prefix, true)) {
                        throw new \Exception("Invalid XML Namespace ($prefix) Data: ");
                    }
                    $perNamespace[$prefix] = $nsXml;
                }
                if (1 === count($perNamespace)) {
                    return current($perNamespace);
                }

                return $perNamespace;
            }

            return $xml;
        } catch (\Exception $ex) {
            $xmlstr = explode("\n", $xml_string);
            $errstr = "[INVALIDREQUEST]: Invalid XML Data: ";
            foreach (libxml_get_errors() as $error) {
                $errstr .= static::displayXmlError($error, $xmlstr) . "\n";
            }
            libxml_clear_errors();
            throw new \Exception($errstr);
        }
    }
329369
def raw_xml(self) -> _RawXML:
        
        if self._xml:
            return self._xml
        else:
            return etree.tostring(self.element, encoding='unicode').strip().encode(self.encoding)
676724
def get_xml_text(source, path=None):
  
  if path is None:
    return source.text
  else:
    return get_xml_text(get_xml_child(source, path))
318353
def lxml(self) -> _LXML:
        
        if self._lxml is None:
            self._lxml = etree.fromstring(self.raw_xml)

        return self._lxml
147729
def parse_xml_layers(xml_layers):
        
        layers = []
        for custom_map_source in xml_layers.getchildren():
            layers.append(MapSource.parse_xml_layer(custom_map_source))
        return layers
1333787
def xpath(self, xpath_str):
        
        return super(BaseOxmlElement, self).xpath(
            xpath_str, namespaces=_nsmap
        )
1076908
def pretty_xml(string_input, add_ns=False):
    
    if add_ns:
        elem = "<foo "
        for key, value in DOC_CONTENT_ATTRIB.items():
            elem += ' %s="%s"' % (key, value)
        string_input = elem + ">" + string_input + "</foo>"
    doc = minidom.parseString(string_input)
    if add_ns:
        s1 = doc.childNodes[0].childNodes[0].toprettyxml("  ")
    else:
        s1 = doc.toprettyxml("  ")
    return s1
1184140
def get_elements(self, tag_name, attribute):
        
        l = []
        for i in self.xml:
            for item in self.xml[i].getElementsByTagName(tag_name):
                value = item.getAttributeNS(NS_ANDROID_URI, attribute)
                value = self.format_value(value)

                l.append(str(value))
        return l
661042
def parse(string)
      LibXML::XML.default_keep_blanks = false

      if string.blank?
        {}
      else
        LibXML::XML::Parser.string(string.strip).parse.to_hash
      end
    end