You need to sign in to do that
Don't have an account?
upNcommN
C# XML manipulation possibilities
I know this is a little out of sforce's scope, but i'm trying to improve code efficiency.
Is it possible to convert/cast the sObject's XmlElement array into an MSXML parser object or some similar construct so that the nodes are accessible via XPath strings? I'm unsure of any other way of locating nodes in sObjects beyond looping through the names which is very messy. I'm using C#.
thanks
aj
This will convert any object that supports serialization (like all of the SForce objects) into an XmlElement.
Michael S. Scherotter
Business Solutions Architect
Mindjet LLC
static XmlElement ToXMLElement(object rObject)
{
XmlSerializer ser = new XmlSerializer(rObject.GetType() );
StringWriter writer = new StringWriter();
ser.Serialize( writer, rObject);
XmlDocument doc = new XmlDocument();
doc.LoadXml(writer.ToString());
return doc.DocumentElement;
}
I know that you can do this by manipulating the generated C# from the web reference. Is there a way to do this without changing the generated code?
Michael
thanks guys, very helpful
aj
well those solutions work great, what would be the equivalent operations in java?
aj
Hi upNcommN,
I think you can do this with the org.apache.axis.encoding.ser package. I've not done it myself, but I'd start there.