Skip to content

Commit

Permalink
Add: Add a new function to parse XML data into an Element tree
Browse files Browse the repository at this point in the history
Add a common function to convert bytes or str into a Element tree.
  • Loading branch information
bjoernricks authored and greenbonebot committed Jun 14, 2024
1 parent 3bc26a8 commit 5e05c98
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gvm/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import sys
from io import IOBase
from typing import List, Optional, TextIO, Union
from typing import AnyStr, List, Optional, TextIO, Union

import defusedxml.lxml as secET
from defusedxml import DefusedXmlException
Expand All @@ -24,6 +24,12 @@ def create_parser():
return XMLParser(encoding="utf-8", huge_tree=True)


def parse_xml(xml: AnyStr) -> Element:
parser = create_parser()
parser.feed(xml)
return parser.close()


class XmlCommandElement:
def __init__(self, element):
self._element = element
Expand Down

0 comments on commit 5e05c98

Please sign in to comment.