Convert or cast object[] to xml document and retrieve values from xml nodes
What is the most optimized code for converting an object[] to an xml document? In a function from a service the return type is object [] and the object returned contains a list of xml elements. So I need to convert this object[] to xml for data retrieval.
Also what is the most optimized code for ret开发者_JAVA技巧rieving values from a particular node ( say node with name project) and values as list ( ABC, XYZ) by navigating through the xml document given?
<?xml version="1.0" encoding="utf-8" ?>
<ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<anyType>
<attributes xmlns="http://services.abc.com">
<attributes>
<name>projectdetails</name>
<values>
<values>ABC</values>
<values>XYZ</values>
</values>
</attributes>
</anyType>
</ArrayOfAnyType>
XMLSerializer does a pretty good job on serializing any objects.
No idea on optimized..it's .net..so it probably uses an optimal data structure for this(perhaps a b tree).
Here is an article on the topic. http://robseder.wordpress.com/2010/03/18/the-deal-with-xmlserializer-being-so-slow-%E2%80%93-finally/
精彩评论