Q: openxml wordprocessing extended attributes I'm converting an HTML table to openxml using "AlternativeChunck"
AlternativeFormatImportPart AFIT = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.Html, altChunkId);
AFIT.FeedData(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(myHTML)));
AltChunk altChunk = new AltChunk();
altChunk.Id = altChunkId;
mainPart.Document.Body.Append(altChunk);

Table cells have some attributes that I need after conversion to openxml table. At least I need an ID tag or attribute to find each cell after conversion to XML and perform some actions based on that ID. How shall I define ID tag in html that it will be available in XML after conversion?

A: I'm making 2 assumptions: 


*

*You aren't building the HTML yourself, otherwise you would add the id attribute to each cell as you build the HTML. 

*The HTML is well-formed XML. 


Based on the above assumptions, I would pre-process the HTML using either XSLT or LINQ to XML before appending it to the document body. If doing LINQ to XML, try something like this:
    public static string PreProcessHTML(string html)
    {
        string rtn = "";

        System.IO.StringReader rdr = new StringReader(html);
        XElement root = XElement.Load(rdr);
        var tds = root.Descendants("td");
        int i = 0;
        foreach (XElement td in tds)
        {
            td.SetAttributeValue("id", "id" + i.ToString());
            i++;
        }

        rtn = root.ToString(SaveOptions.None);
        return rtn;
    }

