Closed waelsaad closed 1 year ago
Is it possible for a SWXMLHash deserialized object to have an exposed .childern
property that can keep track of all the nodes in a sequential manner? In general each deserialized object should be able to know all of its nodes
for child in document.children {
print(child.element!.name)
}
Thanks
I have implemented the .children solution on the deserialized object. I do belive this is something that should be offered by SWXMLHash. Thanks
Hey @waelsaad glad you were able to get it figured out! I was traveling this weekend and saw on my phone, but hadn't had a chance to reply yet. Hope everything is well!
Hi @drmohundro thank you very much and I appreciate the response. I hope you had a safe flight and all is well with you also. :)
Hi,
I really need some help with this question as I have been struggeling with it on my own for some time and I 've been trying lots of different XML libraries but XMLHash is the one I've extensivly spent my time on.
I have 1000+ XML files that I am loading dynamically and the order of how the nodes and the sub nodes appear is important to perserve because each XML file will be turned into a readable article in a SwiftUI view.
I have already implemented a solution for my problem using recursive for loops using this approach to handle all the different types of nodes:
However I created a completely deserializable model that covers all the possible scenarios of how the nodes and its sub nodes can appear and I would like to loop thru that deserialized object directly once we read the content of the XML file in a SwiftUI view and try to render it correctly.
Probablly in the same way if we were trying to render a HTML file to display all the nodes in the same order. I need to do the same for my XML files but from the deserializable object.
I am not sure what is the best approach to do this.
Please let me know if I haven't explained my problem properlly or you need me to paste code attempts. If you know of a solution please share. Thanks
Here is a simple version of a sample XML file structure but please keep in minde how the sub nodes are nested and their order can be different for every other file.
This is incorrect implementation because the order of the nodes is still messed up. but you get the idea.