Click here to Skip to main content
15,896,505 members
Please Sign up or sign in to vote.
2.20/5 (3 votes)
See more:
Please help me in solving the error. My Problem is I actually getting xml String from Web service,
I am storing that string into XML File and reading the file using xml.reader();

But will getting the string from web service if there is empty xml node the node is geting in single tag Ex:
XML
<Data_Classification />

instead of
XML
<Data_Classification></Data_Classification>

Following is the code I am writing to store xml string to xml file.

Code:
C#
private static void  printMessage(string strBody)
{			 
    sring strPath =Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings["PrintMsgPath"]); 
    if(!Directory.Exists(strPath))
    {
        Directory.CreateDirectory(strPath);
    }
    if (!File.Exists(strPath+"\\APMIRIS.xml")) 
    {
        using (StreamWriter sw = File.CreateText(strPath+"\\APMIRIS.xml")) 
        {				
            sw.WriteLine(strBody);				
        }	
    }
    else
    {
        File.Delete(strPath+"\\APMIRIS.xml");		
//      using (StreamWriter sw1 = File.Delete(strPath+"\\APMIRIS.xml")) 
//      {
        using (StreamWriter sw2 = File.CreateText(strPath+"\\APMIRIS.xml")) 
        {	
            sw2.WriteLine(strBody);					
        }					
    }
}


Please let me know the where I am going wrong?
Posted
Updated 14-May-13 2:45am
v6
Comments
ZurdoDev 14-May-13 8:11am    
There is nothing wrong. That is a valid xml tag. What is the actual issue?
Ameen Sherif 14-May-13 8:39am    
I think you are getting the right answer. <data_classification> and <data_classification></data_classification> are same. Then what is bothering you </data_classification>

1 solution

There is no actual difference between
<Data_Classification></Data_Classification>

and
<data_classification />


An XML reader/writer which is compatible with the XML standard will read both values equally.

cheers,
Marco Bertschi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900