Skip to content

Commit

Permalink
Merge pull request #5 from MaRDI4NFDI/basicDC
Browse files Browse the repository at this point in the history
Write to xml demo
  • Loading branch information
physikerwelt authored Nov 1, 2023
2 parents fbf6907 + 77ca052 commit 4a58ad7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
7 changes: 0 additions & 7 deletions getPublicationInfo.py

This file was deleted.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ build-backend = "setuptools.build_meta"
name = "zbmath_rest2oai"
description = "convert from custom api to oai-pmh api"
dynamic = ["version"]
requires = [
"requests",
dependencies = [
"requests"
]
[project.optional-dependencies]
test = [
Expand Down
Empty file added src/__init__.py
Empty file.
Empty file added src/zbmath_rest2oai/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions src/zbmath_rest2oai/getPublicationInfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import requests

from zbmath_rest2oai.xml_writer import create_document

url = 'https://api.zbmath.org/document/6383667'

x = requests.get(url)

res = x.json()

print(create_document(res).toprettyxml())
9 changes: 9 additions & 0 deletions src/zbmath_rest2oai/xml_writer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from xml.dom import minidom # Create XML document


def create_document(json: dict):
xmld = minidom.Document()
root = xmld.createElement("root")
root.appendChild(xmld.createTextNode( str ( json.get('result').get('id')) ))
xmld.appendChild(root)
return xmld

0 comments on commit 4a58ad7

Please sign in to comment.