Skip to content

Commit 4f52119

Browse files
feat:xmltodict
1 parent 0ab455a commit 4f52119

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed

util/xml/xmltodict/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# xmltodict
2+
3+
Python module that makes working with XML feel like you are working with JSON
4+
5+
## Related documents
6+
7+
git: https://github.com/martinblech/xmltodict

util/xml/xmltodict/base.ipynb

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"vscode": {
7+
"languageId": "plaintext"
8+
}
9+
},
10+
"source": [
11+
"# dict to xml\n"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": 14,
17+
"metadata": {},
18+
"outputs": [
19+
{
20+
"name": "stdout",
21+
"output_type": "stream",
22+
"text": [
23+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
24+
"<project><actions></actions><description></description><keepDependencies>false</keepDependencies><properties><com.sonyericsson.rebuild.RebuildSettings plugin=\"rebuild@332.va_1ee476d8f6d\"><autoRebuild>false</autoRebuild><rebuildDisabled>true</rebuildDisabled></com.sonyericsson.rebuild.RebuildSettings></properties></project>\n"
25+
]
26+
}
27+
],
28+
"source": [
29+
"import xmltodict\n",
30+
"\n",
31+
"d = js = {\n",
32+
" \"project\": {\n",
33+
" \"actions\": None,\n",
34+
" \"description\": None,\n",
35+
" \"keepDependencies\": \"false\",\n",
36+
" \"properties\": {\n",
37+
" \"com.sonyericsson.rebuild.RebuildSettings\": {\n",
38+
" \"@plugin\": \"rebuild@332.va_1ee476d8f6d\",\n",
39+
" \"autoRebuild\": \"false\",\n",
40+
" \"rebuildDisabled\": \"true\",\n",
41+
" }\n",
42+
" },\n",
43+
" \n",
44+
" }\n",
45+
"}\n",
46+
"x = xmltodict.unparse(d)\n",
47+
"print(x)"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {
53+
"vscode": {
54+
"languageId": "plaintext"
55+
}
56+
},
57+
"source": [
58+
"# xml to dict\n"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": 13,
64+
"metadata": {},
65+
"outputs": [
66+
{
67+
"name": "stdout",
68+
"output_type": "stream",
69+
"text": [
70+
"{'project': {'actions': None, 'description': None, 'keepDependencies': 'false'}}\n"
71+
]
72+
}
73+
],
74+
"source": [
75+
"with open(\"file/test.xml\") as f:\n",
76+
" rest = xmltodict.parse(f.buffer)\n",
77+
" print(rest)"
78+
]
79+
}
80+
],
81+
"metadata": {
82+
"kernelspec": {
83+
"display_name": ".venv",
84+
"language": "python",
85+
"name": "python3"
86+
},
87+
"language_info": {
88+
"codemirror_mode": {
89+
"name": "ipython",
90+
"version": 3
91+
},
92+
"file_extension": ".py",
93+
"mimetype": "text/x-python",
94+
"name": "python",
95+
"nbconvert_exporter": "python",
96+
"pygments_lexer": "ipython3",
97+
"version": "3.12.5"
98+
}
99+
},
100+
"nbformat": 4,
101+
"nbformat_minor": 2
102+
}

util/xml/xmltodict/file/test.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<project>
3+
<actions></actions>
4+
<description></description>
5+
<keepDependencies>false</keepDependencies>
6+
</project>

util/xml/xmltodict/pyproject.toml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[tool.poetry]
2+
name = "xmltodict"
3+
version = "0.1.0"
4+
description = ""
5+
authors = ["colorfulgray0 <colorfulgray0@gmail.com>"]
6+
readme = "README.md"
7+
8+
[tool.poetry.dependencies]
9+
python = "^3.12"
10+
xmltodict = "^0.14.2"
11+
12+
[build-system]
13+
requires = ["poetry-core"]
14+
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)