having problem in writing the character '&' in word doc , by using open xml sdk RRS feed

  • General discussion

  • Dear All,

    I have made this xml to fill out the word template by using offcourse open xml sdk

      string newXML = "<root>" +
                                      "<AssociateName>"+AssociateName+"</AssociateName>" +
                                      "<EmpID>"+EmpID+"</EmpID>" +
                                      "<GiftAmount>"+GiftAmount+"</GiftAmount>" +
                                      "<GiftDate>"+GiftDate+"</GiftDate>" +
                                      "<HomeStreetAddress>"+HomeStreetAddress+"</HomeStreetAddress>" +
                                      "<NPOName>"+NPOName+"</NPOName>" +
                                      "<CityName>"+CityName+"</CityName>" +
                                      "<StateName>"+StateName+"</StateName>" +
                                      "<ZipCode>"+ZipCode+"</ZipCode>" +
                                      "<NPStreetAddress>"+NPStreetAddress+"</NPStreetAddress>" +
                                      "<WorkEmail>"+WorkEmail+"</WorkEmail>" +
                                      "<NPCity>"+NPCity+"</NPCity>" +
                                      "<NPState>"+NPState+"</NPState>" +
                                      "<NPZipCode>"+NPZipCode+"</NPZipCode>" +
                                      "<WorkPhone>"+WorkPhone+"</WorkPhone>" +
                                      "<DivisionName>" + DivisionName + "</DivisionName>" +
                                      "<LocationName>"+LocationName+"</LocationName>" +

    the problem i am having is this that DIVISION NAME is " Systems & Services " , (comes from the sql database) and when it does it corrupts the word file and when i open it it says the "Word File cannot be opene dbecause there is a problem with the contents" , so i dig to find out wat content is creating the problem and it turned out to be '&' character is Systems & Services , cause if u remove & char the word file open perfectly with data populated , please help how can i over come this so the '&' char dont creat problem :-(

    Friday, May 4, 2012 12:00 PM

All replies

  • well it turned out to be that i had to replace the  '&' with &amp; and then it worked fine so my issue got resolved

    here is the link

    Friday, May 4, 2012 1:08 PM