2014-09-12 47 views
0

我試圖讓這個輸出:設計一個表格內的XmlWriter

<thead> 
    <tr><th>Condition</th><th>Effective Dates</th><th>Condition Status</th></tr> 
</thead> 

,但我得到這個:

<thead> 
    <tr> 
     <th>DX Code</th> 
     <th>Date</th> 
     <th>Code Type</th> 
    </tr> 
</thead> 

我似乎無法得到的元素顯示在單一線。 我這個代碼是:

doc.WriteStartElement("thead"); 
    doc.WriteStartElement("tr"); 
    doc.WriteStartElement("th"); 
    doc.WriteString("DX Code"); 
    doc.WriteEndElement(); 
    doc.WriteStartElement("th"); 
    doc.WriteString("Date"); 
    doc.WriteEndElement(); 
    doc.WriteStartElement("th"); 
    doc.WriteString("Code Type"); 
    doc.WriteEndElement(); 
    doc.WriteEndElement(); 
    doc.WriteEndElement(); 

有越來越格式化,如第一個例子中的一種方式?我試着用WriteString,但是全部換成了「<」和「>」與XML「& LT」和「& GT」

回答

0

好,我知道它會通過調用doc.WriteWhiteSpace(「」)工作; (「tr」)元素之後。這會暫停indent/newline直到(「tr」)元素結束。