Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7415965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:23:59+00:00 2026-05-29T07:23:59+00:00

Im using Open XML SDK to read and write information to custom xml parts

  • 0

Im using Open XML SDK to read and write information to custom xml parts in a Word document.
Im serializing a xml structure into a class , modifying the data and serializing it back into the document.

Example code

DocumentFormat.OpenXml.Packaging.CustomXmlPart myPart = GetCustomXmlPart(mainPart, AITNamespaces.SiteDataNameSpace);
StreamReader myStrR = new System.IO.StreamReader(myPart.GetStream());
string myXML = myStrR.ReadToEnd();
sitedata = ObjectXMLSerializer<WDSiteData>.LoadString(myXML);

Site selSite = _applicationService.GetApplicationData().Sites.Find(item => item.Id == siteId);

sitedata.SiteId= selSite.Id;
sitedata.SiteName = "ööööaaaaaåååå"; // selSite.SiteName;

myXML = ObjectXMLSerializer<WDSiteData>.GetXMLString(sitedata);
myPart = GetCustomXmlPart(wordProcDocument.MainDocumentPart, AITNamespaces.SiteDataNameSpace);
using (StreamWriter sw = new StreamWriter(myPart.GetStream(FileMode.Create)))
{
    sw.Write(myXML);
}

My problem is that the national characters become encoded and the text “ööööaaaaaåååå” is displayed in the word document as “????????aaaaa????????”

The actual encoding is done

myXML = ObjectXMLSerializer<WDSiteData>.GetXMLString(sitedata);

Anyone has a clue on how to go about handling national characters this way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:24:00+00:00Added an answer on May 29, 2026 at 7:24 am

    For whom it concerns , my trouble was that in my serializer the encoding was fixed

    return ASCIIEncoding.ASCII.GetString(memStream.ToArray());
    

    When i changed to

    return ASCIIEncoding.UTF8.GetString(memStream.ToArray());
    

    all is well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I built a template-based document generator using the Open XML SDK (1.0) , the
In my app I am using the open xml sdk to generate a word
I am using c#4.0 and open xml sdk 2.0 for accessing Word file.For that,
I'm trying to merge two docx-documents into one docx-document using OpenXML SDK 2.0. The
I'm using Microsoft Open XML SDK 2 and I'm having a really hard time
From aspx page, I dynamically add paragraphs to a word document using OpenXml SDK.
Using the Open XML SDK I've been successful in programatically finding bookmarks or text
I am exporting my data into Excel Using Open XML . now i want
I'm using the Open XML SDK 2.0 to open an Excel file. When I
I have created an Excel document using OpenXml SDK 2.0, now I have to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.