Beispiel #1
0
    def generate_xml_blocks(self):
        et.register_namespace("efxpt", "http://www.efinixinc.com/peri_design_db")
        tree = et.parse(self.filename + ".peri.xml")
        root = tree.getroot()

        for block in self.xml_blocks:
            if isinstance(block, InterfaceWriterXMLBlock):
                block.generate(root, namespaces)
            else:
                if block["type"] == "LVDS":
                    self.add_lvds_xml(root, block)
                if block["type"] == "DRAM":
                    self.add_dram_xml(root, block)

        if self.platform.iobank_info:
            self.add_iobank_info_xml(root, self.platform.iobank_info)

        xml_string = et.tostring(root, "utf-8")
        reparsed = expatbuilder.parseString(xml_string, False)
        print_string = reparsed.toprettyxml(indent="    ")

        # Remove lines with only whitespaces. Not sure why they are here
        print_string = os.linesep.join([s for s in print_string.splitlines() if s.strip()])

        tools.write_to_file("{}.peri.xml".format(self.filename), print_string)
Beispiel #2
0
def openAPIparse(string, parser=None):
    if parser is None:
        from xml.dom import expatbuilder
        return expatbuilder.parseString(string)
    else:
        from xml.dom import pulldom
        return pulldom.parseString()
Beispiel #3
0
    def from_str(svg_str: str):
        svg_path_groups = []
        svg_dom = expatbuilder.parseString(svg_str, False)
        svg_root = svg_dom.getElementsByTagName('svg')[0]

        viewbox_list = list(
            map(float,
                svg_root.getAttribute("viewBox").split(" ")))
        view_box = Bbox(*viewbox_list)

        primitives = {
            "path": SVGPath,
            "rect": SVGRectangle,
            "circle": SVGCircle,
            "ellipse": SVGEllipse,
            "line": SVGLine,
            "polyline": SVGPolyline,
            "polygon": SVGPolygon
        }

        for tag, Primitive in primitives.items():
            for x in svg_dom.getElementsByTagName(tag):
                svg_path_groups.append(Primitive.from_xml(x))

        return SVG(svg_path_groups, view_box)
Beispiel #4
0
    def GetFileListForYearMonth(self, dates):
        '''
        gets a list of the files available for the specific date requested
        '''
        fileListArray = []

        url = self.baseUrl +  \
            "/browse/results" + \
            "/" + dates + \
            "/files"
        try:
            self.logger.debug(self.moduleName + " -- " +
                              "GetFileListForYearMonth" + " starting ")
            req = requests.post(url, data=self.logonCreds)
            if req.status_code == 200:
                xmldoc = parseString(req.text)
                itemlist = xmldoc.getElementsByTagName('fileName')
                for elm in itemlist:
                    for cn in elm.childNodes:
                        fileListArray.append(cn.nodeValue.encode())
            else:
                errorMsg = "HTTP Code: " + str(
                    req.status_code) + " Message: " + str(req.text)
                self.logger.exception(self.moduleName + " - " + errorMsg)
                raise Exception(errorMsg)

            self.logger.debug(self.moduleName + " -- " +
                              "GetFileListForYearMonth" + " finished ")
        except:
            self.logger.exception(
                self.moduleName +
                " - we had an error in GetFileListForYearMonth")
            raise
        return fileListArray
Beispiel #5
0
    def GetAvailableYearMonthsInTotem(self):
        '''
        Get list of all the available year-months available in Totem
        '''
        returnValue = []
        url = self.baseUrl + "/browse/results/dirlist"
        try:
            self.logger.debug(self.moduleName + " -- " + "GetDates" +
                              " starting ")

            req = requests.post(url, data=self.logonCreds)

            if req.status_code == 200:
                xmldoc = parseString(req.text)
                itemlist = xmldoc.getElementsByTagName('directory')
                for elm in itemlist:
                    for cn in elm.childNodes:
                        returnValue.append(cn.nodeValue.encode())
            else:
                errorMsg = "HTTP Code: " + str(
                    req.status_code) + " Message: " + str(req.text)
                self.logger.exception(self.moduleName + " - " + errorMsg)
                raise Exception(errorMsg)

            self.logger.debug(self.moduleName + " -- " + "GetDates" +
                              " finished ")
        except:
            self.logger.exception(self.moduleName +
                                  " - we had an error in GetDates")
            raise
        return returnValue
    def transform(self, input: str):
        """
            expects FeatureType xml node as String from WFS capabilites document as input
        """

        featureTypeDOM = expatbuilder.parseString(input, False)
        collection = self.parseFeatureType(featureTypeDOM)

        return collection
Beispiel #7
0
    def write_graph(self, filename):
        self.generate_graphml()

        graph_xml = ET.tostring(self.graphml, encoding='UTF-8', method='xml').decode('UTF-8')

        dom = expatbuilder.parseString(graph_xml, False)
        pretty_xml_as_string = dom.toprettyxml()

        f = open(filename, "w")
        f.write(pretty_xml_as_string)
        f.close()
Beispiel #8
0
 def _get_plist_node(self):
     dom = parseString(self._binary_data)
     for child in self._get_next_element(dom):
         tree = child
         break
     for child in self._get_next_element(tree):
         if child is None:
             raise RuntimeError("dict node for plist not found")
         if child.nodeName == "dict":
             tree = child
             break
     return tree
Beispiel #9
0
    def build_project(self):
        now = datetime.datetime.now()

        # Create Project.
        root = et.Element("efx:project")
        root.attrib["xmlns:efx"] = "http://www.efinixinc.com/enf_proj"
        root.attrib["name"] = self._build_name
        root.attrib["location"] = str(pathlib.Path().resolve())
        root.attrib[
            "sw_version"] = "2021.1.165.2.19"  # TODO: read it from sw_version.txt
        root.attrib[
            "last_change_date"] = f"Date : {now.strftime('%Y-%m-%d %H:%M')}"

        # Add Device.
        device_info = et.SubElement(root, "efx:device_info")
        et.SubElement(device_info, "efx:family", name=self.platform.family)
        et.SubElement(device_info, "efx:device", name=self.platform.device)
        et.SubElement(device_info,
                      "efx:timing_model",
                      name=self.platform.timing_model)

        # Add Design Info.
        design_info = et.SubElement(root, "efx:design_info")
        et.SubElement(design_info, "efx:top_module", name=self._build_name)

        # Add Design Sources.
        for filename, language, library, *copy in self.platform.sources:
            if language is None:
                continue
            et.SubElement(
                design_info, "efx:design_file", {
                    "name": filename,
                    "version": "default",
                    "library": "default" if ".vh" not in filename else library,
                })

        # Add Timing Constraints.
        constraint_info = et.SubElement(root, "efx:constraint_info")
        et.SubElement(constraint_info,
                      "efx:sdc_file",
                      name=f"{self._build_name}.sdc")

        # Add Misc Info.
        misc_info = et.SubElement(root, "efx:misc_info")

        # Add IP Info.
        ip_info = et.SubElement(root, "efx:ip_info")

        # Generate .xml
        xml_str = et.tostring(root, "utf-8")
        xml_str = expatbuilder.parseString(xml_str, False)
        xml_str = xml_str.toprettyxml(indent="  ")
        tools.write_to_file("{}.xml".format(self._build_name), xml_str)
def main_resps():
    in_file = Path("data/resps_citations.txt")
    bibs = parse_citations(in_file)

    ET.register_namespace(
        "xlmns:b",
        "http://schemas.openxmlformats.org/officeDocument/2006/bibliography")
    top = Element("b:Sources")
    top.extend([b.to_word_xml() for b in bibs])

    xml_str = expatbuilder.parseString(tostring(top), False).toprettyxml()
    with open("resps.xml", "w") as f:
        f.write(xml_str)
    def as_string(self) -> str:
        xml_string = self._xml_file.as_string()
        document = expatbuilder.parseString(xml_string, False)
        events = document.getElementsByTagName('log4j:event')
        csv = self.get_column_heads()
        row_num = 0

        for ev in events:
            row_num += 1
            csv += "\n\"" + str(row_num) + "\"" + ", "
            event = DomEvent(ev)
            event_csv_row = EventCsvRow(event)
            row_string = event_csv_row.as_string()
            csv += row_string

        return csv
Beispiel #12
0
    def generate_xml_blocks(self):
        et.register_namespace('efxpt', "http://www.efinixinc.com/peri_design_db")
        tree = et.parse(self.filename + '.peri.xml')
        root = tree.getroot()

        for block in self.xml_blocks:
            if block['type'] == 'LVDS':
                self.add_ddr_lvds(root, block)

        xml_string = et.tostring(root, 'utf-8')
        reparsed = expatbuilder.parseString(xml_string, False)
        print_string = reparsed.toprettyxml(indent="    ")

        # Remove lines with only whitespaces. Not sure why they are here
        print_string = os.linesep.join([s for s in print_string.splitlines() if s.strip()])

        tools.write_to_file("{}.peri.xml".format(self.filename), print_string)
Beispiel #13
0
 def _searchTitles(self,title,limit="1",iteration=0):
     if(title.__len__()<2):
         return ""
     req = urllib.request.Request("http://mymovieapi.com/?type=xml&plot=none&episode=0&yg=0&mt=M&lang=en-US&offset=&aka=simple&release=simple&business=0&tech=0&title="+title+"&limit="+limit,headers={'User-Agent' : ""})
     con = urllib.request.urlopen(req)
     result=con.read()
     i=0
     dom = parseString(result)
     for node in dom.getElementsByTagName("IMDBDocumentList"):
         for node2 in node.getElementsByTagName("title"):
             movie=Movie()
             movie.title=node.getElementsByTagName("title")[i].firstChild.nodeValue
             movie.id=node.getElementsByTagName("imdb_id")[i].firstChild.nodeValue
             movie.rating=node.getElementsByTagName("rating")[i].firstChild.nodeValue
             movie.year=node.getElementsByTagName("year")[i].firstChild.nodeValue
             sonuc=movie
             i=i+1
             return sonuc
         #success
     return self.titleManipulateRight(title,limit,iteration+1)
Beispiel #14
0
    def fix_xml_values(self):
        et.register_namespace("efxpt",
                              "http://www.efinixinc.com/peri_design_db")
        tree = et.parse(self.filename + ".peri.xml")
        root = tree.getroot()
        for tag, name, values in self.fix_xml:
            for e in tree.iter():
                if (tag in e.tag) and (name == e.get("name")):
                    for n, v in values:
                        e.set(n, v)

        xml_string = et.tostring(root, "utf-8")
        reparsed = expatbuilder.parseString(xml_string, False)
        print_string = reparsed.toprettyxml(indent="    ")

        # Remove lines with only whitespaces. Not sure why they are here
        print_string = os.linesep.join(
            [s for s in print_string.splitlines() if s.strip()])

        tools.write_to_file("{}.peri.xml".format(self.filename), print_string)
Beispiel #15
0
    def GetDates(self):
        '''
        get the dates available
        '''
        ##
        #  purpose is to make a call and find all the relevant dates based on parameters
        ##
        retVal = []
        ##
        # generate the base url that we plan to use
        ##
        url = self.baseUrl +  \
            "/browse/results/dirlist"
        try:
            ##
            # make the call
            ##
            self.logger.debug(self.moduleName + " -- " + "GetDates" +
                              " starting ")

            req = requests.post(url, data=self.logonCreds)

            if req.status_code == 200:
                xmldoc = parseString(req.text)
                itemlist = xmldoc.getElementsByTagName('directory')
                for elm in itemlist:
                    for cn in elm.childNodes:
                        retVal.append(cn.nodeValue.encode())
            else:
                errorMsg = "HTTP Code: " + str(
                    req.status_code) + " Message: " + str(req.text)
                self.logger.exception(self.moduleName + " - " + errorMsg)
                raise Exception(errorMsg)

            self.logger.debug(self.moduleName + " -- " + "GetDates" +
                              " finished ")
        except:
            self.logger.exception(self.moduleName +
                                  " - we had an error in GetDates")
            raise
        return retVal
Beispiel #16
0
 def as_cpe_lang_xml(expr):
     s = '<cpe-lang:platform id="' + expr.as_id(
     ) + '">' + expr.as_cpe_lang_xml() + '</cpe-lang:platform>'
     # A primitive but simple way to pretty-print an XML string
     return expatbuilder.parseString(s, False).toprettyxml()
Beispiel #17
0
def _build_xml(partnumber, timing_model, build_name, sources, additional_xml_commands):

    root = et.Element('efx:project')

    now = datetime.datetime.now()
    date_str = " Date: " + now.strftime("%Y-%m-%d %H:%M") + " "

    # Add the required attributes
    root.attrib['xmlns:efx'] = 'http://www.efinixinc.com/enf_proj'
    root.attrib['xmlns:xsi'] = "http://www.w3.org/2001/XMLSchema-instance"
    root.attrib['name'] = build_name
    root.attrib['description'] = ''
    root.attrib['last_change_date'] = date_str
    root.attrib['location'] = str(pathlib.Path().resolve())
    root.attrib['sw_version'] = '2021.1.165.2.19' # TODO: read it from sw_version.txt
    root.attrib['last_run_state'] = ''
    root.attrib['last_run_tool'] = ''
    root.attrib['last_run_flow'] = ''
    root.attrib['config_result_in_sync'] = 'sync'
    root.attrib['design_ood'] = 'sync'
    root.attrib['place_ood'] = 'sync'
    root.attrib['route_ood'] = 'sync'
    root.attrib['xsi:schemaLocation'] = 'http://www.efinixinc.com/enf_proj enf_proj.xsd'

    device_info = et.SubElement(root, 'efx:device_info')
    et.SubElement(device_info, 'efx:family', name = 'Trion')
    et.SubElement(device_info, 'efx:device', name = partnumber)
    et.SubElement(device_info, 'efx:timing_model', name = timing_model)

    design_info = et.SubElement(root, 'efx:design_info')
    et.SubElement(design_info, "efx:top_module", name = build_name)
    for filename, language, library in sources:
        if '.vh' not in filename:
            val = {'name':filename, 'version':'default', 'library':'default'}
            et.SubElement(design_info, "efx:design_file", val)
    et.SubElement(design_info, "efx:top_vhdl_arch", name = "")

    constraint_info  = et.SubElement(root, "efx:constraint_info")
    et.SubElement(constraint_info, "efx:sdc_file", name = "{}.sdc".format(build_name))

    misc_info  = et.SubElement(root, "efx:misc_info")
    ip_info  = et.SubElement(root, "efx:ip_info")

    synthesis  = et.SubElement(root, "efx:synthesis", tool_name="efx_map")
    for l in additional_xml_commands:
        if l[0] == 'efx_map':
            val = {'name':l[1], 'value':l[2], 'value_type':l[3]}
            et.SubElement(synthesis, "efx:param", val)

    place_and_route  = et.SubElement(root, "efx:place_and_route", tool_name="efx_pnr")
    for l in additional_xml_commands:
        if l[0] == 'efx_pnr':
            val = {'name':l[1], 'value':l[2], 'value_type':l[3]}
            et.SubElement(place_and_route, "efx:param", val)

    bitstream_generation  = et.SubElement(root, "efx:bitstream_generation", tool_name="efx_pgm")
    for l in additional_xml_commands:
        if l[0] == 'efx_pgm':
            val = {'name':l[1], 'value':l[2], 'value_type':l[3]}
            et.SubElement(bitstream_generation, "efx:param", val)

    xml_string = et.tostring(root, 'utf-8')
    reparsed = expatbuilder.parseString(xml_string, False)
    print_string = reparsed.toprettyxml(indent="  ")

    # Generate .xml
    tools.write_to_file("{}.xml".format(build_name), print_string)
def addfilestoCN(componentNetwork, fpga_component, files, solution_name):
    cn = expatbuilder.parse(componentNetwork, False)
    implementation_number = 0

    for component in cn.getElementsByTagName('component'):
        if component.getAttribute('name') == fpga_component:
            for implementation in component.getElementsByTagName(
                    'implementation'):
                if int(implementation.getAttribute(
                        'id')) > implementation_number:
                    implementation_number = int(
                        implementation.getAttribute('id'))

            newimpl = cn.createElement("implementation")
            newimpl.setAttribute("target", "fpga")
            newimpl.setAttribute("id", str(implementation_number + 1))

            # Modified component files
            for root, directories, filenames in os.walk(files[0]):
                for filename in filenames:
                    filepath = os.path.join(files[0], filename)
                    filetype = "".join(pathlib.Path(filename).suffixes)[1:]
                    if os.path.isfile(filepath):
                        if filetype != "" and filetype != "h":
                            relpath, filename = os.path.split(filepath)
                            newsrc = cn.createElement("source")
                            newsrc.setAttribute("file", filename)
                            newsrc.setAttribute("lang", filetype)
                            newsrc.setAttribute(
                                "path",
                                os.path.join(
                                    repository_ipcoregen_source, solution_name,
                                    os.path.relpath(files[0],
                                                    generated_src_dir)))
                            newimpl.appendChild(newsrc)
                    else:
                        print("{} is not a valid file.".format(filepath))

            # Xilinx Autogenerated drivers
            for root, directories, filenames in os.walk(files[1]):
                for filename in filenames:
                    filepath = os.path.join(files[1], filename)
                    filetype = "".join(pathlib.Path(filename).suffixes)[1:]
                    if os.path.isfile(filepath):
                        if filetype != "" and filetype != "h":
                            relpath, filename = os.path.split(filepath)
                            newsrc = cn.createElement("source")
                            newsrc.setAttribute("file", filename)
                            newsrc.setAttribute("lang", filetype)
                            newsrc.setAttribute(
                                "path",
                                os.path.join(
                                    repository_ipcoregen_source, solution_name,
                                    os.path.relpath(files[0],
                                                    generated_src_dir),
                                    'drivers'))
                            newimpl.appendChild(newsrc)
                    else:
                        print("{} is not a valid file.".format(filepath))

            # IP Core Zip
            relpath, filename = os.path.split(files[2])
            newsrc = cn.createElement("source")
            newsrc.setAttribute("file", filename)
            newsrc.setAttribute("lang", "ipcore")
            newsrc.setAttribute(
                "path", os.path.join(repository_ipcoregen_source,
                                     solution_name))
            newimpl.appendChild(newsrc)

            # Write XML
            component.appendChild(newimpl)
            cnstring = cn.toprettyxml().replace("\r", "").replace("\n", "")
            cn = expatbuilder.parseString(cnstring, False)
            f = open(componentNetwork, "w+")
            cn.writexml(f, "", "\t", "\n")
            f.close()
import xml.dom.expatbuilder as bad
import defusedxml.expatbuilder as good

bad.parse('filethatdoesntexist.xml')
good.parse('filethatdoesntexist.xml')

xmlString = "<note>\n<to>Tove</to>\n<from>Jani</from>\n<heading>Reminder</heading>\n<body>Don't forget me this weekend!</body>\n</note>"

bad.parseString(xmlString)
good.parseString(xmlString)
Beispiel #20
0
# -*- coding: utf-8 -*-
import xml.dom.expatbuilder as bad
import defusedxml.expatbuilder as good

bad.parse("filethatdoesntexist.xml")
good.parse("filethatdoesntexist.xml")

xmlString = "<note>\n<to>Tove</to>\n<from>Jani</from>\n<heading>Reminder</heading>\n<body>Don't forget me this weekend!</body>\n</note>"

bad.parseString(xmlString)
good.parseString(xmlString)
Beispiel #21
0
    def checkout(self, payment_method, bank_code, order_code, total_amount,
                 order_description, return_url, cancel_url, buyer_fullname,
                 buyer_email, buyer_mobile, buyer_address):
        """
        Hàm lấy link thanh toán dùng số dư ví ngân lượng
        ===============================
        Tham số truyền vào bắt buộc phải có
                 order_code
                 total_amount
                 payment_method

                 buyer_fullname
                 buyer_email
                 buyer_mobile
        ===============================
         array_items mảng danh sách các item name theo quy tắc
         item_name1
         item_quantity1
         item_amount1
         item_url1
         .....

         payment_type Kiểu giao dịch:
            1 - Ngay;
            2 - Tạm giữ; Nếu không truyền hoặc bằng rỗng thì lấy theo chính
            sách của NganLuong.vn
        """
        params = {
            'cur_code': self.cur_code,
            'receiver_email': self.receiver_email,
            'function': nl_function,
            'version': nl_version,
            'merchant_id': self.merchant_id,
            # Mã merchant khai báo tại NganLuong.vn
            'merchant_password': self.merchant_password,
            # MD5(Mật khẩu kết nối giữa merchant và NganLuong.vn)
            'order_code': order_code,  # Mã hóa đơn do website bán hàng sinh ra
            'total_amount': total_amount,  # Tổng số tiền của hóa đơn
            'payment_method': payment_method,  # Phương thức thanh toán
            'bank_code': bank_code,  # Mã Ngân hàng
            'payment_type': 1,
            'order_description': order_description,  # Mô tả đơn hàng
            'tax_amount': 0,  # Tổng số tiền thuế
            'fee_shipping': 0,  # Phí vận chuyển
            'discount_amount': 0,  # Số tiền giảm giá
            'return_url': return_url,
            # Địa chỉ website nhận thông báo giao dịch thành công
            'cancel_url': cancel_url,  # Địa chỉ website nhận "Hủy giao dịch"
            'buyer_fullname': buyer_fullname,  # Tên người mua hàng
            'buyer_email': buyer_email,  # Địa chỉ Email người mua
            'buyer_mobile': buyer_mobile,  # Điện thoại người mua
            'buyer_address': buyer_address,  # Địa chỉ người mua hàng
        }

        result = nl_fetch_url(service_vars=params)
        get_error = NganLuongCheckout.get_error_message
        if result is not None:
            try:
                result = result.replace('&', '&amp;')
                nl_xml = expatbuilder.parseString(result)
                data = dict()
                tags = nl_xml.getElementsByTagName("error_code")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["error_code"] = ""
                    else:
                        error_code = tags.item(0).firstChild.data
                        data["error_code"] = error_code
                        if not error_code == "00":
                            data["error_code"] = get_error(error_code)
                else:
                    data["error_code"] = ""

                tags = nl_xml.getElementsByTagName("token")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["token"] = ""
                    else:
                        data["token"] = tags.item(0).firstChild.data
                else:
                    data["token"] = ""

                tags = nl_xml.getElementsByTagName("description")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["description"] = ""
                    else:
                        data["description"] = tags.item(0).firstChild.data
                else:
                    data["description"] = ""

                tags = nl_xml.getElementsByTagName("time_limit")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["time_limit"] = ""
                    else:
                        data["time_limit"] = tags.item(0).firstChild.data
                else:
                    data["time_limit"] = ""

                tags = nl_xml.getElementsByTagName("checkout_url")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["checkout_url"] = ""
                    else:
                        data["checkout_url"] = tags.item(0).firstChild.data
                else:
                    data["checkout_url"] = ""

                return data
            except Exception as ex:
                print "Error NganLuong: " + str(ex)
                return dict(error_code=str(ex))
        return None
Beispiel #22
0
    def get_transaction_detail(self, token):
        params = {
            'merchant_id': self.merchant_id,
            'merchant_password': self.merchant_password,
            'version': nl_version,
            'function': 'GetTransactionDetail',
            'token': token
        }
        result = nl_fetch_url(service_vars=params)
        if result is not None:
            try:
                result = result.replace('&', '&amp;')
                nl_xml = expatbuilder.parseString(result)
                data = dict(token=token)
                tags = nl_xml.getElementsByTagName("error_code")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["error_code"] = ""
                    else:
                        error_code = tags.item(0).firstChild.data
                        data["error_code"] = error_code
                        if not error_code == "00":
                            data["error_code"] = self.get_error_message(
                                error_code)
                else:
                    data["error_code"] = ""

                tags = nl_xml.getElementsByTagName("total_amount")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["total_amount"] = ""
                    else:
                        data["total_amount"] = tags.item(0).firstChild.data
                else:
                    data["total_amount"] = ""

                tags = nl_xml.getElementsByTagName("order_description")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["order_description"] = ""
                    else:
                        data["order_description"] = tags.item(
                            0).firstChild.data
                else:
                    data["order_description"] = ""

                tags = nl_xml.getElementsByTagName("order_code")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["order_code"] = ""
                    else:
                        data["order_code"] = tags.item(0).firstChild.data
                else:
                    data["order_code"] = ""

                tags = nl_xml.getElementsByTagName("transaction_id")
                if tags.length > 0:
                    if tags.item(0).firstChild is None:
                        data["transaction_id"] = ""
                    else:
                        data["transaction_id"] = tags.item(0).firstChild.data
                else:
                    data["transaction_id"] = ""

                return data
            except Exception as ex:
                print "Error NganLuong: " + str(ex)
                return None
        return None