Updating the Existing XML through Code

Posted by Shoyebaziz123 under ASP.NET on 8/7/2010 | Views : 1134 | Status : [Member] | Replies : 1
Hi Friends,

i am updating an existing xml...in that xml all tags are well formed wirh blank data, i am using this code to fill the data

str = Server.MapPath("./XMLFile/abc.xml")

mXmlDataSet.Tables("AssesseeName").Rows(0).Item("FirstName") = "A"
mXmlDataSet.Tables("AssesseeName").Rows(0).Item("MiddleName") ="B"
mXmlDataSet.Tables("AssesseeName").Rows(0).Item("SurNameOrOrgName") =""
mXmlDataSet.Tables("PersonalInfo").Rows(0).Item("PAN") ="ABCDE1234M"
mXmlDataSet.Tables("Address").Rows(0).Item("ResidenceNo") ="RES123"
mXmlDataSet.Tables("Address").Rows(0).Item("ResidenceName") =""
mXmlDataSet.Tables("Address").Rows(0).Item("RoadOrStreet") ="ROAD"
mXmlDataSet.Tables("Address").Rows(0).Item("LocalityOrArea") ="AREA"
mXmlDataSet.Tables("Address").Rows(0).Item("CityOrTownOrDistrict") = "CITY"
mXmlDataSet.Tables("Address").Rows(0).Item("StateCode") ="19"
mXmlDataSet.Tables("Address").Rows(0).Item("PinCode") ="4458899"
mXmlDataSet.Tables("Phone").Rows(0).Item("STDcode") = "022"
mXmlDataSet.Tables("Phone").Rows(0).Item("PhoneNo") ="123456"
mXmlDataSet.Tables("Address").Rows(0).Item("EmailAddress") = "abcd@xyz.com"
mXmlDataSet.Tables("PersonalInfo").Rows(0).Item("DOB") ="1980-09-25"
mXmlDataSet.Tables("PersonalInfo").Rows(0).Item("EmployerCategory") = "GOV"
mXmlDataSet.Tables("PersonalInfo").Rows(0).Item("Gender") ="M"
mXmlDataSet.Tables("PersonalInfo").Rows(0).Item("Status") = "I"

mPath = Server.MapPath("./XMLFileManagement/201011/")
mXmlDataSet.WriteXml(mPath & "/" & "123" & ".xml")

all works correctly ,fill rocord correctly but my problem is that if there is blank or no record then this particular tag should be delete/comment in o/p
xml (surname and address tag here)... further more the swquence of xml should not be distrub it should be in same manner as i have written here... the last four tag shows first what is the reason .. how can i solve it.

Thanks in advance


Posted by: Vuyiswamb on: 11/4/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Why dont you add the XML to a dataset and remove the blank record from there and take it back again to Xml

Thank you for posting at Dotnetfunda

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response