I recently wrote some code that took an XML DOM object and returned an object in Javascript. After talking with a co-worker I am questioning if this is a worth while approach.
Do any of you know of any research or articles that discuss the pros and cons of using either approach?
Example: My code would take a XML DOM object with a structure like this (code changed because of NDA):
<myObject id="123" anotherAttr="hello" customAttr="foo">
<myChild name="child1" foo="bar"/>
<myChild name="child2" foo="bar"/>
<myChild name="child3" foo="bar"/>
</myObject>
and would return this:
{
id: "123",
anotherAttr: "hello",
customAttr: "foo",
children: [
{name: "child1", foo: "bar"},
{name: "child2", foo: "bar"},
{name: "child3", foo: "bar"}
]
}
The three main reasons I would do this:
- The code is more readable. (with the object I can access the values with dot notation)
- I always thought that working with objects was faster than working with the DOM.
Again my question is: Do any of you know of any research or articles that discuss the pros and cons of using either approach? Am I way off base on my assumptions?