Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

xml - Export data does not allow newlines c#

I export data form XML with results:

cu302
cu1701
cd1701
cc432

I wana show resuilts: ,cu302,cu1701

Is there any solution for the text to not have a line break?

+Add more question: In XML file with content:

<ns1:TestXML name="1:u302">
<ns1:IndictmentXML algorithm="s192059844" indictmentType="Billboarding">
<ns1:RepairActionXML repairOperator="c_admin" repairTime="2021-01-21T07:45:58.000+07:00" repairActionType="-" indictmentType="Billboarding" comment="-" repairStatus="Repaired"/>
<ns1:ComponentXML packageId="192059844" partId="192059844" designator="1:u302"/>
</ns1:IndictmentXML>
</ns1:TestXML>
<ns1:TestXML name="1:d1701">
<ns1:IndictmentXML algorithm="bdiode-cr316" indictmentType="Wrong Polarity">
<ns1:RepairActionXML repairOperator="c_admin" repairTime="2021-01-21T07:45:51.000+07:00" repairActionType="-" indictmentType="Wrong Polarity" comment="-" repairStatus="False Call"/>
</ns1:IndictmentXML>
</ns1:TestXML>

how to sort tag ,how to filter out the results of: Repaired and False Call? Please help me advice

question from:https://stackoverflow.com/questions/65876685/export-data-does-not-allow-newlines-c-sharp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you can define a empty string and add each line data to it:

var result = string.Empty;
foreach (XElement ComponentXML in doc.Descendants(ns1 + "ComponentXML"))
       foreach (var cRD in ComponentXML.Attributes("designator"))
               result += $"c{cRD.Value.Substring(2)}, ";

sw.writeLine(result)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...