0
Reply

XmlDocument Vs StringBuilder

anup daware

anup daware

Feb 8 2007 2:56 AM
2.2k

Hi Group,

 

You might have found the Title a little strange :); well following is the problem description:

I want to form a SOAP xml request to a servlet, I have my Request xml template ready.

Now I have following options:

1.       Load the xml template in an XmlDocument object and manipulate it.

2.       Load the xml template in a StringBuilder object, manipulate it and then load it in XmlDocument.

3.       Not using any template and creating the xml from scratch.

Following is the sample xml template which I will use:

<?xml version="1.0" encoding="UTF-8"?>

<MT_MaterialSearchRequest>

 <!-- Customer Data -->

 <CUSTOMER> CUSTOMER _PLACEHOLDER</CUSTOMER>

 <SALES_ORG> SALES_ORG _ PLACEHOLDER </SALES_ORG>

 <!-- Limit on the size of the search result -->

 <DEFAULT_SORTING> DEFAULT_SORTING _PLACEHOLDER</DEFAULT_SORTING>

  <!-- Material Data -->

<WIDTH> WIDTH _HOLDER</WIDTH>

 <SERIE> SERIE _HOLDER</SERIE>

<!-- Material List -->

 <VISIBILITY_ITEM_IN>

  <ITEM> <!—NOTE: Number of <ITEM> nodes is dynamic>

     <MATERIAL></MATERIAL>

 </ITEM>

<ITEM>

 <MATERIAL></MATERIAL>

 </ITEM>

 </VISIBILITY_ITEM_IN>

</MT_MaterialSearchRequest>

 

My Questions:

1.       For this scenario which of the above mentioned options which is more suitable?

2.       In General which options is more preferable?

3.       I know that second option of using StringBuilder is going to be very easy for implementation, but which option is better in terms of speed of execution and memory considerations?

 

Hoping to get some expert comments on this :)

 
Thanks,

Anup Daware