python类getElementsByTagName()的实例源码

xml_cdr.py 文件源码 项目:CommunityCellularManager 作者: facebookincubator 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
xml_cdr.py 文件源码 项目:CommunityCellularManager 作者: facebookincubator 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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
xml_cdr.py 文件源码 项目:CommunityCellularManager 作者: facebookincubator 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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
test_minidom.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def testGetElementsByTagName(self):
        dom = parse(tstfile)
        self.confirm(dom.getElementsByTagName("LI") == \
                dom.documentElement.getElementsByTagName("LI"))
        dom.unlink()
test_minidom.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_toprettyxml_preserves_content_of_text_node(self):
        # see issue #4147
        for str in ('<B>A</B>', '<A><B>C</B></A>'):
            dom = parseString(str)
            dom2 = parseString(dom.toprettyxml())
            self.assertEqual(
                dom.getElementsByTagName('B')[0].childNodes[0].toxml(),
                dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
test_minidom.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def testGetElementsByTagName(self):
        dom = parse(tstfile)
        self.confirm(dom.getElementsByTagName("LI") == \
                dom.documentElement.getElementsByTagName("LI"))
        dom.unlink()
test_minidom.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_toprettyxml_preserves_content_of_text_node(self):
        # see issue #4147
        for str in ('<B>A</B>', '<A><B>C</B></A>'):
            dom = parseString(str)
            dom2 = parseString(dom.toprettyxml())
            self.assertEqual(
                dom.getElementsByTagName('B')[0].childNodes[0].toxml(),
                dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
test_minidom.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def testGetElementsByTagName(self):
        dom = parse(tstfile)
        self.confirm(dom.getElementsByTagName("LI") == \
                dom.documentElement.getElementsByTagName("LI"))
        dom.unlink()
test_minidom.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_toprettyxml_preserves_content_of_text_node(self):
        # see issue #4147
        for str in ('<B>A</B>', '<A><B>C</B></A>'):
            dom = parseString(str)
            dom2 = parseString(dom.toprettyxml())
            self.assertEqual(
                dom.getElementsByTagName('B')[0].childNodes[0].toxml(),
                dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
test_minidom.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def testGetElementsByTagName(self):
        dom = parse(tstfile)
        self.confirm(dom.getElementsByTagName("LI") == \
                dom.documentElement.getElementsByTagName("LI"))
        dom.unlink()
test_minidom.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_toprettyxml_preserves_content_of_text_node(self):
        # see issue #4147
        for str in ('<B>A</B>', '<A><B>C</B></A>'):
            dom = parseString(str)
            dom2 = parseString(dom.toprettyxml())
            self.assertEqual(
                dom.getElementsByTagName('B')[0].childNodes[0].toxml(),
                dom2.getElementsByTagName('B')[0].childNodes[0].toxml())
test_minidom.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def testGetElementsByTagName(self):
        dom = parse(tstfile)
        self.confirm(dom.getElementsByTagName("LI") == \
                dom.documentElement.getElementsByTagName("LI"))
        dom.unlink()
test_minidom.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_toprettyxml_preserves_content_of_text_node(self):
        # see issue #4147
        for str in ('<B>A</B>', '<A><B>C</B></A>'):
            dom = parseString(str)
            dom2 = parseString(dom.toprettyxml())
            self.assertEqual(
                dom.getElementsByTagName('B')[0].childNodes[0].toxml(),
                dom2.getElementsByTagName('B')[0].childNodes[0].toxml())


问题


面经


文章

微信
公众号

扫码关注公众号