Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
mq:status=""
What i get:
p8:status=""

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");
Posted
Comments
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:
https://pasteboard.co/IaJlqgr.png

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.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900