XML elements not imported when tags not presents in the IDML file.
Opened this issue · 5 comments
Hey, I try to import an XML to the package using import_xml method, but it just keeps adding the attributes, but not the elements.
Any ideas?
BTW, is there any way to change 'import XML options'? I know there are elements defined on Resources/Preferences.xml
Hi,
Does the import of the XML file on the Structure works correctly from InDesign?
Are you using a with
context to perform the import?
Here an example: https://github.com/Starou/SimpleIDML/blob/master/tests/regressiontests/idml.py#L326
Thanks for your reply @Starou
Yes, the XML works fine when imported via Indesign (with all import options set unchecked).
I have added my IDML and my XMl to my project folder and used with
:
with IDMLPackage('my_idml.Idml) as idmlfile, open(my_xml.xml,'r') as xml:
with idmlfile.import_xml(xml.read(),'/Root') as f:
output = f.export_xml()
Output:
Process finished with error code 0.
When entered:
Print (f.export_xml())
The output is:
<Root attrib1="value1" attrib2="value2" />
My_xml.xml file content:
<article attrib1="value1" attrib2="value2">
<title>This is title</title>
<body>Body text goes here</body>
</article>
Seems correct. I need to see the actual files (xml and idml) I guess.
Thanks.
My IDML is a blank file and the XML is the same as I've posted, btw, I've attached them here as a zip archive (GitHub doesn't allow uploading XML).
IDML.zip
PS. Shouldn't newly imported XML structure, override the 'Root' tag?
I have to look into it but my guess is that your IDML document does not contains the tags from your XML in its tag list.
I am marking this a bug that needs to be fixed.
Thanks.