I want to remove the formatting of my xml file after loading into an XDocument. I am having the following code.
Dim xmldoc As XDocument = XDocument.Parse(XMLStr)
.
.
.
.
Dim FinalStr as String = xmldoc.ToString()
when i taking this string i am getting the multiple new lines and multiple spaces. I dont want those spaces and new lines can any one tell me how to remove that.
I know there is an option of SaveOptions.DisableFormatting to remove the format, but i am not going to save the document.
And i tried in Regex also but some of the content spaces also removed, so i want to remove ony the formatting spaces and newline which XDocument puts.
Update:
I tried xmldoc.ToString(SaveOptions.DisableFormatting) but its removing some spaces also. For example, when my xml like this
<title>My <b>tilte</b> <i>Company</i></title>
it removes the space between the <b>tilte</b> <i>Company</i> tags.
I want my title as
"My tilte Company" but it gives "My tilteCompany"
Can any one help me.
I think your problem would be solved using:
For more information visit XDocument.Parse Method (String, LoadOptions)