-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from MaRDI4NFDI/basicDC
Write to xml demo
- Loading branch information
Showing
6 changed files
with
22 additions
and
9 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |