• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python minidom.Element类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xml.dom.minidom.Element的典型用法代码示例。如果您正苦于以下问题:Python Element类的具体用法?Python Element怎么用?Python Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Element类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, name, subtag_name, data, name_att='name'):
     Element.__init__(self, name)
     self.__data_dict__  = {}
     for key, value in data.items():
         self.__data_dict__[key] = TextElement(subtag_name, value)
         self.__data_dict__[key].setAttribute('name', key)
         self.appendChild(self.__data_dict__[key])
开发者ID:BackupTheBerlios,项目名称:useless-svn,代码行数:7,代码来源:xmlfile.py


示例2: __init__

 def __init__(self, apt_id, uri, dist, sections, local_path):
     Element.__init__(self, 'aptsource')
     self.setAttribute('apt_id', apt_id)
     self.setAttribute('uri', uri)
     self.setAttribute('dist', dist)
     self.setAttribute('sections', sections)
     self.setAttribute('local_path', local_path)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:7,代码来源:xmlgen.py


示例3: xml_encode

 def xml_encode(self, text):
     from xml.dom.minidom import Text, Element
     t = Text()
     t.data = text
     e = Element('x')
     e.appendChild(t)
     return e.toxml()[3:-4]
开发者ID:kbriggs,项目名称:gedit-xml-codec,代码行数:7,代码来源:xmlcodec.py


示例4: __init__

 def __init__(self, suite, nonus=False, updates=False, local=False, common=False):
     Element.__init__(self, "suite")
     self.setAttribute("name", suite)
     self.setAttribute("nonus", nonus)
     self.setAttribute("updates", updates)
     self.setAttribute("local", local)
     self.setAttribute("common", common)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:7,代码来源:xmlgen.py


示例5: __init__

 def __init__(self, conn, machines=None):
     raise RuntimeError , "ClientMachineDatabaseElement isn't working"
     Element.__init__(self, 'machine_database')
     self.conn = conn
     if machines is not None:
         self.machines = MachinesElement(conn, machines)
         self.appendChild(self.machines)
开发者ID:joelsefus,项目名称:paella,代码行数:7,代码来源:xmlgen.py


示例6: __init__

 def __init__(self, conn, path='/'):
     Element.__init__(self, 'paelladatabase')
     self.conn = conn
     self.stmt = StatementCursor(self.conn)
     self._profile_traits_ = ProfileTrait(self.conn)
     self.path = path
     self.aptsources = AptSourceListElement()
     self.appendChild(self.aptsources)
     if 'apt_sources' in self.stmt.tables():
         for row in self.stmt.select(table='apt_sources', order=['apt_id']):
             element = AptSourceElement(row.apt_id, row.uri, row.dist, row.sections,
                                        row.local_path)
             self.aptsources.appendChild(element)
         self.suites = SuitesElement()
         self.appendChild(self.suites)
         for row in self._suite_rows():
             args = map(str, [row.suite, row.nonus, row.updates, row.local, row.common])
             element = SuiteElement(*args)
             for suiteapt in self.stmt.select(table='suite_apt_sources', order=['ord'],
                                              clause=Eq('suite', row.suite)):
                 element.appendChild(SuiteAptElement(row.suite,
                                                     suiteapt.apt_id, str(suiteapt.ord)))
             self.suites.appendChild(element)
     else:
         print 'WARNING, apt_sources table does not exist, backing up anyway'
     self.profiles = PaellaProfiles(self.conn)
     self.family = Family(self.conn)
     suites = [x.suite for x in self._suite_rows()]
     for suite in suites:
         self.appendChild(TraitsElement(self.conn, suite))
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:30,代码来源:main.py


示例7: __init__

    def __init__(self, name, type, value, is_array=None,
                 array_size=None, qualifier_scopes={},
                 overridable=None, tosubclass=None,
                 toinstance=None, translatable=None):

        Element.__init__(self, 'QUALIFIER.DECLARATION')
        self.setName(name)
        self.setAttribute('TYPE', type)
        if is_array is not None:
            self.setOptionalAttribute('ISARRAY', str(is_array).lower())
        if array_size is not None:
            self.setAttribute('ARRAYSIZE', str(array_size))
        if overridable is not None:
            self.setAttribute('OVERRIDABLE', str(overridable).lower())
        if tosubclass is not None:
            self.setAttribute('TOSUBCLASS', str(tosubclass).lower())
        if toinstance is not None:
            self.setAttribute('TOINSTANCE', str(toinstance).lower())
        if translatable is not None:
            self.setAttribute('TRANSLATABLE', str(translatable).lower())

        if qualifier_scopes:
            scope = SCOPE(qualifier_scopes)
            self.appendOptionalChild(scope)
        if value is not None:
            if is_array:
                xval = VALUE_ARRAY(value)
            else:
                xval = VALUE(value)
            self.appendOptionalChild(xval)
开发者ID:cloud-hm,项目名称:pywbem3,代码行数:30,代码来源:cim_xml.py


示例8: _add_lang_to_html

def _add_lang_to_html(htmltext, lang):
    '''
    Take a piece of HTML and add an xml:lang attribute to it.
    '''
    if lang == 'und':
        return htmltext
    parser = html5lib.HTMLParser(
        tree=html5lib.treebuilders.getTreeBuilder("dom")
    )
    html = parser.parseFragment(htmltext)
    html.normalize()
    if len(html.childNodes) == 0:
        return '<div xml:lang="%s"></div>' % lang
    elif len(html.childNodes) == 1:
        node = html.firstChild
        if node.nodeType == Node.TEXT_NODE:
            div = Element('div')
            div.ownerDocument = html
            div.setAttribute('xml:lang', lang)
            div.childNodes = [node]
            html.childNodes = [div]
        else:
            node.setAttribute('xml:lang', lang)
    else:
        #add a single encompassing div
        div = Element('div')
        div.ownerDocument = html
        div.setAttribute('xml:lang', lang)
        div.childNodes = html.childNodes
        html.childNodes = [div]
    return html.toxml()
开发者ID:OnroerendErfgoed,项目名称:skosprovider_rdf,代码行数:31,代码来源:utils.py


示例9: __init__

 def __init__(self, name, reference_class=None, array_size=None, qualifiers=[]):
     Element.__init__(self, "PARAMETER.REFARRAY")
     self.setName(name)
     self.setOptionalAttribute("REFERENCECLASS", reference_class)
     if array_size is not None:
         self.setAttribute("ARRAYSIZE", str(array_size))
     self.appendChildren(qualifiers)
开发者ID:anksp21,项目名称:Community-Zenpacks,代码行数:7,代码来源:cim_xml.py


示例10: get

    def get(self, *args):
        self.response.headers['Content-Type'] = "application/rss+xml"

        items = self.getItems(*args)

        itemElems = []
        for item in items:
            itemElem = Element("item")
            self._appendElementWithTextNode(itemElem, "title", item.title)
            self._appendElementWithTextNode(itemElem, "link", item.link)
            self._appendElementWithTextNode(itemElem, "description", item.description)
            self._appendElementWithTextNode(itemElem, "guid", item.link)
            if item.subPlaceFeedLink:
                self._appendElementWithTextNode(itemElem, "sharkattackdata:subPlaceFeedLink", item.subPlaceFeedLink)
            if item.attackFeedLink:
                self._appendElementWithTextNode(itemElem, "sharkattackdata:attackFeedLink", item.attackFeedLink)

            itemElems.append(itemElem)

        # Need to make channel element after the generator returned by getItems has been iterated.
        channelElem = Element("channel")
        self._appendElementWithTextNode(channelElem, "title", self._feedTitle)
        self._appendElementWithTextNode(channelElem, "link", self._feedLink)
        self._appendElementWithTextNode(channelElem, "description", self._feedDescription)

        for itemElem in itemElems:
            channelElem.appendChild(itemElem)

        responseText = """<?xml version="1.0"?>
<rss version="2.0" xmlns:sharkattackdata="http://sharkattackdata.com/rss/modules/1.0/">
%s
</rss>
""" % (channelElem.toprettyxml())
        self.response.out.write(responseText)
开发者ID:ikarajas,项目名称:sharkattackdata,代码行数:34,代码来源:rssfeeds.py


示例11: __init__

    def __init__(self, ownerDocument, name=""):
        Element.__init__(self, TAG_CATEGORY)
        self.name = name
        self.ownerDocument = ownerDocument
        self._items = []

        self.setAttribute("name", self.name)
开发者ID:WangCrystal,项目名称:deepin-movie,代码行数:7,代码来源:playlist.py


示例12: node2xml

def node2xml(node):
    """Takes in a node object and returns an XML object for that node"""
    ele = Element("node")
    for k, v in node.attrs.items():
        ele.setAttribute(k, v)
    for k, v in node.tags.items():
        ele.appendChild(tag2xml(k, v))
    return ele
开发者ID:h4ck3rm1k3,项目名称:pyxbot,代码行数:8,代码来源:obj2xml.py


示例13: _getElementForMappingEntry

 def _getElementForMappingEntry(entry, mappingStyle):
     e = Element(mappingStyle)
     for k, v in entry.items():
         # ignore empty, None or compiled regexp items into output
         if not v or (k == "path-match-expr"):
             continue
         e.setAttribute(k, str(v))
     return e
开发者ID:dciangot,项目名称:WMCore,代码行数:8,代码来源:TrivialFileCatalog.py


示例14: __init__

 def __init__(self, mnt_name, mnt_point, fstype, mnt_opts, dump, pass_):
     Element.__init__(self, "mount")
     self.setAttribute("mnt_name", mnt_name)
     self.setAttribute("mnt_point", mnt_point)
     self.setAttribute("fstype", fstype)
     self.setAttribute("mnt_opts", mnt_opts)
     self.setAttribute("dump", dump)
     self.setAttribute("pass", pass_)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:8,代码来源:xmlgen.py


示例15: set_scripts

 def set_scripts(self):
     self.scripts = [x.script for x in self.traitscripts.scripts(self.name)]
     while self.scripts_element.hasChildNodes():
         del self.scripts_element.childNodes[0]
     for script in self.scripts:
         element = Element('script')
         element.setAttribute('name', script)
         self.scripts_element.appendChild(element)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:8,代码来源:trait.py


示例16: __init__

 def __init__(self):
     Element.__init__(self, 'paelladatabase')
     self.aptsources = AptSourceListElement()
     self.appendChild(self.aptsources)
     self.suites_element = SuitesElement()
     self.suites = {}
     self.suite_traits = {}
     self.appendChild(self.suites_element)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:8,代码来源:main.py


示例17: __init__

 def __init__(self, conn):
     Element.__init__(self, 'profiles')
     self.conn = conn
     self.stmt = StatementCursor(self.conn)
     self.env = ProfileEnvironment(self.conn)
     self.profiletraits = ProfileTrait(self.conn)
     self._profiles = {}
     for row in self.stmt.select(table='profiles', order='profile'):
         self._append_profile(row.profile, row.suite)
开发者ID:BackupTheBerlios,项目名称:paella-svn,代码行数:9,代码来源:profile.py



注:本文中的xml.dom.minidom.Element类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pulldom.parse函数代码示例发布时间:2022-05-26
下一篇:
Python minidom.Document类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap