Click here to Skip to main content
14,428,304 members
Rate this:
Please Sign up or sign in to vote.
See more:
I need to export a modified xliff file from my c# tool, but during the modification a different pre-tag is used instead the one I wish to use:
What i wish to appear is:
What i get:

I tried to read after this, and now I know that the pre-tags somehow relate to namespaces, but dunno how I can change it or add the "pre-tag" I want.

What I have tried:

This is the code which should change the file's content:

XDocument doc = XDocument.Load(filePath);
            XElement xliff = (XElement)doc.FirstNode;
            XNamespace ns = xliff.Name.Namespace;

            var testid = xliff.Descendants(ns + "trans-unit");

            foreach (var item in testid)
                var iD = Convert.ToInt16(item.FirstAttribute.Value) - 1;
                item.SetAttributeValue(ns + "status", units[iD].Status);
                item.SetAttributeValue(ns + "locked", units[iD].isLocked);

            doc.Save(destination + "\\EXPORT.mqxliff");
Richard MacCutchan 18-Apr-19 8:17am
What is in ns when you run the code?
Member 13050667 18-Apr-19 10:21am
this is the line: NamespaceName = "urn:oasis:names:tc:xliff:document:1.2"
Richard MacCutchan 18-Apr-19 11:35am
1. That does not answer my question.
2. That line of code does not exist in the snippet above.
Member 13050667 18-Apr-19 12:45pm
Sorry, Im a beginner. Thats all what I can see:

If this is not what you want please rephrase.
Richard MacCutchan 18-Apr-19 13:03pm
If you do not understand the code that you have written it is a bit difficult to offer much advice. However, the little triangle to the left of that line in the debugger suggests you can expand that line to see exactly what the content of the variable is.
Member 13050667 18-Apr-19 13:45pm
I understand my code, but not how to handle those attributes with the namespace thing before them.
I saw that I can expand that field, but haven't found anything useful:
Richard MacCutchan 18-Apr-19 13:58pm
Sorry, but the only thing I can suggest is to look at the documentation for the XML classes that you are trying to use.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,188
Richard MacCutchan 1,919
phil.o 1,280
Patrice T 1,247
MadMyche 1,185

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100