Generates xml for Dictionary and Entry objects.

 Returns String.
199912
def to_xml
      xml = ""
      xml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
      xml << "<d:dictionary xmlns=\"http://www.w3.org/1999/xhtml\" "
      xml << "xmlns:d=\"http://www.apple.com/DTDs/DictionaryService-1.0.rng\">\n"
      @entries.each do |entry|
        next if entry.to_xml.nil?

        xml << entry.to_xml
      end
      xml << "</d:dictionary>"

      return xml
    end
229662
def xml(self):
        
        root = Element('UsernameToken', ns=wssens)
        u = Element('Username', ns=wssens)
        u.setText(self.username)
        root.append(u)
        p = Element('Password', ns=wssens)
        p.setText(self.password)
        if self.password_digest:
            p.set("Type", wsdigest)
            p.setText(self.password_digest)
        root.append(p)
        if self.nonce is not None:
            n = Element('Nonce', ns=wssens)
            if self.nonce_has_encoding:
                n.set("EncodingType", nonce_encoding_type)
            n.setText(self.nonce)
            root.append(n)
        if self.created is not None:
            n = Element('Created', ns=wsuns)
            n.setText(str(DateTime(self.created)))
            root.append(n)
        return root
1129009
def toxml(self):
        
        chxmlstr = ''

        for with_ in self.withs:
            chxmlstr += with_.toxml()

        for event_connection in self.event_connections:
            chxmlstr += event_connection.toxml()

        for child_instance in self.child_instances:
            chxmlstr += child_instance.toxml()

        for multi_instantiate in self.multi_instantiates:
            chxmlstr += multi_instantiate.toxml()

        for for_each in self.for_eachs:
            chxmlstr += for_each.toxml()

        if chxmlstr:
            xmlstr = '<Structure>' + chxmlstr + '</Structure>'
        else:
            xmlstr = ''

        return xmlstr
1277926
def gen_xml_doc(self):
        
        res = self.make_doc()
        var_tag = """
        <text:user-field-decl office:value-type="string"
        office:string-value="%s" text:name="py3o.%s"/>"""
        text_tag = """<text:p text:style-name="P1">
            <text:user-field-get text:name="py3o.%s">%s</text:user-field-get>
        </text:p>
        """
        keys = res.keys()
        keys.sort()
        texts = ""
        vars = ""
        for key in keys:
            value = res[key]
            vars += var_tag % (value, key)
            texts += text_tag % (key, value)
        return CONTENT_TMPL % (vars, texts)
1240094
def get_result_xml(result):
    
    result_xml = Element('result')
    for name, value in [('name', result['name']),
                        ('type', ResultType.get_str(result['type'])),
                        ('severity', result['severity']),
                        ('host', result['host']),
                        ('test_id', result['test_id']),
                        ('port', result['port']),
                        ('qod', result['qod'])]:
        result_xml.set(name, str(value))
    result_xml.text = result['value']
    return result_xml
35193
def toxml(self):
        

        return '<ComponentRequirement name="{0}"'.format(self.name) + '' + \
            (' description = "{0}"'.format(self.description) if self.description else '') +\
            '/>'
859684
def parse(self, root):
        """"""
        #Use the first element in the versions list since there should only be one.
        v = _get_xml_version(root)[0]
        result = {}

        for child in root:         
            if child.tag in self.versions[v].entries:
                entry = self.versions[v].entries[child.tag]
                #Entry can be either a line or a group. Both objects have a parse
                #method that returns a list of values. In the line's case, the
                #list is the values from that line. For the group, it is a list
                #of dictionaries, a dictionary for each tag name.
                result[child.tag] = entry.parse(child)

        return result
124878
def generate_xmltags(fn, returntag, ignore_tags, ns=None):
    
    xmlns = create_namespace(ns)
    ns_ignore = ['{0}{1}'.format(xmlns, x) for x in ignore_tags]
    for ac, el in etree.iterparse(fn):
        if el.tag == '{0}{1}'.format(xmlns, returntag):
            yield el
        elif el.tag in ns_ignore:
            formatting.clear_el(el)
1239635
def toxml(self):
        

        return '<Property name="{0}"'.format(self.name) +\
          (' dimension="{0}"'.format(self.dimension) if self.dimension else 'none') +\
          (' defaultValue = "{0}"'.format(self.default_value) if self.default_value else '') +\
          '/>'
573168
def to_xml
			result_string = String.new
			result_string << "<results>\n"
			@results.each do |result|
				result_string << "\t<vtresult>\n"
				RESULT_FIELDS.each{|field|
					result_string << "\t\t<#{field.to_s}>#{result[field]}</#{field.to_s}>\n" unless field == :permalink and result['permalink'].nil?
				}
				result_string << "\t</vtresult>\n"
			end if @results != nil
			result_string << "</results>\n"

			result_string
		end
866850
def _xml_to_dict(xml_to_convert):
    

    logger.debug("Converting to Python dict this XML: " + str(xml_to_convert))
    return xmltodict.parse(xml_to_convert, attr_prefix='')
1171919
def toxml(self):
        

        xmlstr = '<OnEvent port="{0}"'.format(self.port)

        chxmlstr = ''

        for action in self.actions:
            chxmlstr += action.toxml()

        if chxmlstr:
            xmlstr += '>' + chxmlstr + '</OnEvent>'
        else:
            xmlstr += '/>'

        return xmlstr
241364
def toxml(self):
        

        return '<Record quantity="{0}" scale="{1}" color="{2}" id="{3}"/>'.format(self.quantity,
                                                                         self.scale,
                                                                         self.color,
                                                                         self.id)
199127
def xmltreefromstring(s):
    """"""
    if sys.version < '3':
        #Python 2
        if isinstance(s,unicode): #pylint: disable=undefined-variable
            s = s.encode('utf-8')
        try:
            return ElementTree.parse(StringIO(s), ElementTree.XMLParser(collect_ids=False))
        except TypeError:
            return ElementTree.parse(StringIO(s), ElementTree.XMLParser()) #older lxml, may leak!!!!
    else:
        #Python 3
        if isinstance(s,str):
            s = s.encode('utf-8')
        try:
            return ElementTree.parse(BytesIO(s), ElementTree.XMLParser(collect_ids=False))
        except TypeError:
            return ElementTree.parse(BytesIO(s), ElementTree.XMLParser())
1355228
def xml2dict(root):
    
    output = {}
    if root.items():
        output.update(dict(root.items()))

    for element in root:
        if element:
            if len(element) == 1 or element[0].tag != element[1].tag:
                one_dict = xml2dict(element)
            else:
                one_dict = {ns(element[0].tag): xml2list(element)}

            if element.items():
                one_dict.update(dict(element.items()))
            output.update({ns(element.tag): one_dict})

        elif element.items():
            output.update({ns(element.tag): dict(element.items())})

        else:
            output.update({ns(element.tag): element.text})

    return output
1004682
def queueEntryToXML(queueEntry):
    

    xmlRoot = etree.Element(QXML + "queueEntry", nsmap=QXML_NSMAP)
    arkTag = etree.SubElement(xmlRoot, QXML + "ark")
    arkTag.text = queueEntry.ark
    oxumTag = etree.SubElement(xmlRoot, QXML + "oxum")
    oxumTag.text = queueEntry.oxum
    urlListLinkTag = etree.SubElement(xmlRoot, QXML + "urlListLink")
    urlListLinkTag.text = queueEntry.url_list
    statusTag = etree.SubElement(xmlRoot, QXML + "status")
    statusTag.text = queueEntry.status
    if hasattr(queueEntry, "harvest_start") and queueEntry.harvest_start:
        startTag = etree.SubElement(xmlRoot, QXML + "start")
        if isinstance(queueEntry.harvest_start, basestring):
            startTag.text = queueEntry.harvest_start
        else:
            startTag.text = queueEntry.harvest_start.strftime(
                TIME_FORMAT_STRING
            )
    if hasattr(queueEntry, "harvest_end") and queueEntry.harvest_end:
        endTag = etree.SubElement(xmlRoot, QXML + "end")
        if isinstance(queueEntry.harvest_end, basestring):
            endTag.text = queueEntry.harvest_end
        else:
            endTag.text = queueEntry.harvest_end.strftime(TIME_FORMAT_STRING)
    positionTag = etree.SubElement(xmlRoot, QXML + "position")
    positionTag.text = str(queueEntry.queue_position)
    return xmlRoot
1294790
def toxml(self):
        

        return '<ComponentReference name="{0}" type="{1}"'.format(self.name, self.type) + \
          (' local = "{0}"'.format(self.local) if self.local else '') + \
            '/>'