xml_cdr.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:CommunityCellularManager 作者: facebookincubator 项目源码 文件源码
def from_xml(cls, src):
        """Generate instance of subclass from an XML string."""
        dom = xml.dom.minidom.parseString(src)
        # Make sure all of the necessary pieces are there.  Fail if any
        # required tags are missing
        xc = cls()
        for tag_name, default_or_type in xc.required_tags():
            elem = dom.getElementsByTagName(tag_name)
            if not elem:
                raise ValueError("Missing XML tag: " + tag_name)
            tag_type = (default_or_type
                        if isinstance(default_or_type, type)
                        else type(default_or_type))
            xc[tag_name] = tag_type(cls._get_text(elem[0].childNodes))
        return xc
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号