James Gibbs wrote:I think I've got pretty close with the code so far...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
James Gibbs wrote:I think I've got pretty close with the code so far...
James. Please DontWriteLongLines (←click); it makes your thread very hard to read.
I'd break them up myself, but there are tons of them, so I suggest you do it yourself (Use the 'Edit' button).
Thanks
Winston
James Gibbs wrote:
I'm really at the end of my tether trying to figure this out. I'm tempted just to fudge it, ignore the xml hierarchy and for each node write in the xml itself who it's parent is:
James Gibbs wrote:The problem is it looks like I'd have to build the objects first, then deserialize it to xml. Which would mean I'd have to build a separate program to do a one off manual input run for each catagory. Seems like a lot of overhead when I can just write the xml out manually once?
William Brogden wrote:I have not really been following this but the following usage of getFirstChild():
is absolutely deadly. Sometimes (frequently) that first child will be a Text type Node that you don't even think about when working on the logic.
Bill
Junilu Lacar wrote:
James Gibbs wrote:The problem is it looks like I'd have to build the objects first, then deserialize it to xml. Which would mean I'd have to build a separate program to do a one off manual input run for each catagory. Seems like a lot of overhead when I can just write the xml out manually once?
Just to make sure we're on the same page here, deserializing means taking XML and creating an object graph/hierarchy from it, whereas serializing is taking an object graph/hierarchy and generating XML. I thought your goal was to deserialize some XML.
I'm not clear on what you mean by having to "build a separate program to do one off manual input run for each catagory[sic]" (correct spelling is category, BTW). It seems to me that after you've defined your objects and annotated them appropriately for Simple XML framework, all you would need to do is something like their deserialization example:
Am I missing something?
James Gibbs wrote:
My original aim was to take a xml file (which I had already hand typed) then deserialize it to my custom objects. From what I could see Simple XML didn't let you deserialize an XML file of custom objects which wasn't first serialized using Simple XML itself.
My needs have now changed and I'll calling the Amazon Product API for the XML files. I've taken another look at Simple XML and am I right in thinking I could use the templating feature to build a template which understands the schema of the xml amazon returns?
James Gibbs wrote:
... build a template which understands the schema of the xml amazon returns?
Thanks for the input. I didn't use that implementation in the end. By" text type node" do you mean that the text of the first child node might not be what you were expecting?
Junilu Lacar wrote:
as long as you have the proper annotations in your objects.
Junilu Lacar wrote:
I doubt that the templating feature is what you need. The templating feature is useful for when you have XML that contains placeholder tokens of the form "${token.name}" and you want to replace these tokens with actual values which you have in memory.
I can't imagine that the Amazon XML has placeholder tokens in it but if it does, then you can probably use the templating feature. Otherwise, just figure out how to annotate your objects in a way that Simple XML can match it with incoming XML.
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|