当我尝试将以下csv文件转换为xml文件时,我得到以下xml文件。我有三个问题:
注意:这是一个家庭作业。
csv文件:
Parts
输出xml文件:
STUDENT ID,STUDENT NAME,STUDENT SURNAME,COURSE CODE,COURSE CREDIT,MID1,MID2,HW1,HW2,HW3,FINAL,GRADE,STATUS
2015700001,Mesut,GAVGA,CME2202,3,68,74,80,75,65,70,CB,Successful
2015700001,Mesut,GAVGA,CME3004,4,36,32,0,0,,40,FF,Failed
2015700001,Mesut,GAVGA,CME2206,3,80,75,85,78,70,82,BB,Successful
2015700001,Mesut,GAVGA,CME2204,3,90,90,100,96,88,85,AA,Successful
2016700018,Merve Rana,SARI,CME2202,3,0,0,0,0,0,0,D,Absent
2016700018,Merve Rana,SARI,CME2204,3,55,57,0,66,60,48,DC,Successful
2016700018,Merve Rana,SARI,CME2206,3,60,65,70,70,63,60,CC,Successful
2015700022,Nadir,ÖZCAN,CME2202,3,98,95,98,90,92,85,AA,Successful
2015700022,Nadir,ÖZCAN,CME3004,4,85,90,88,90,,90,AA,Successful
2015700022,Nadir,ÖZCAN,CME2206,3,90,78,95,90,88,92,AA,Successful
2016700019,Mehmet Emin,TATLI,CME2204,3,20,12,0,25,0,30,FF,Failed
2016700019,Mehmet Emin,TATLI,CME2206,3,15,0,0,0,0,0,D,Absent
2015700030,Ali,SALMANLI,CME2202,3,82,77,100,98,100,68,BA,Successful
2015700030,Ali,SALMANLI,CME3004,4,76,80,80,80,,67,BB,Successful
2015700030,Ali,SALMANLI,CME3006,4,80,,70,75,,75,BB,Successful
2015700030,Ali,SALMANLI,CME2204,3,90,94,95,90,88,80,AA,Successful
2015700031,Selin,BAYTUR,CME2202,3,40,38,0,20,25,26,FF,Failed
2015700031,Selin,BAYTUR,CME3004,4,65,60,72,65,,58,CC,Successful
2015700031,Selin,BAYTUR,CME2204,3,60,48,50,52,50,60,DC,Successful
2016700020,Oğulcan,ÖZARSLAN,CME2202,3,65,80,100,100,95,85,BA,Successful
2016700020,Oğulcan,ÖZARSLAN,CME2206,3,86,88,90,90,100,100,AA,Successful
2015700042,Murat,GÜREL,CME2204,3,40,0,0,50,20,38,FF,Failed
2015700042,Murat,GÜREL,CME2202,3,71,63,65,74,70,60,CB,Successful
2016700035,Sercan,ERGÖRMÜŞ,CME3006,4,100,,100,95,,88,AA,Successful
2016700036,Çağla,PAK,CME3006,4,47,,52,60,,38,DD,Successful
2016700036,Çağla,PAK,CME2206,3,0,0,0,0,0,0,D,Absent
2016700036,Çağla,PAK,CME2204,3,8,18,0,25,50,35,FF,Failed
2016700037,Kerim,KENAR,CME2206,3,70,75,80,80,72,75,BB,Successful
2016700037,Kerim,KENAR,CME2204,3,80,80,85,56,70,48,CB,Successful
2016700050,Eda,CANSEVER,CME3006,4,45,,70,70,,94,BB,Successful
2015700081,Orkun,TANER,CME2204,3,95,88,70,86,100,75,BA,Successful
2015700081,Orkun,TANER,CME2206,3,100,100,98,98,80,100,AA,Successful
2016700052,Ceren,ÖZTÜRK,CME3004,4,50,0,65,40,,45,DC,Failed
2015700085,Tarık,BABAOĞLU,CME2202,3,0,0,0,0,0,0,D,Absent
C源代码:
<?xml version="1.0" encoding="UTF-8"?>
<studentInfo>
<students>
<STUDENT ID>2015700001</STUDENT ID>
<STUDENT NAME>Mesut</STUDENT NAME>
<STUDENT SURNAME>GAVGA</STUDENT SURNAME>
<COURSE CODE>CME2202</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>68</MID1>
<MID2>74</MID2>
<HW1>80</HW1>
<HW2>75</HW2>
<HW3>65</HW3>
<FINAL>70</FINAL>
<GRADE>CB</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2015700001</STUDENT ID>
<STUDENT NAME>Mesut</STUDENT NAME>
<STUDENT SURNAME>GAVGA</STUDENT SURNAME>
<COURSE CODE>CME3004</COURSE CODE>
<COURSE CREDIT>4</COURSE CREDIT>
<MID1>36</MID1>
<MID2>32</MID2>
<HW1>0</HW1>
<HW2>0</HW2>
<HW3>00</HW3>
<FINAL>0</FINAL>
</students>
<students>
<STUDENT ID>2015700001</STUDENT ID>
<STUDENT NAME>Mesut</STUDENT NAME>
<STUDENT SURNAME>GAVGA</STUDENT SURNAME>
<COURSE CODE>CME2206</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>80</MID1>
<MID2>75</MID2>
<HW1>85</HW1>
<HW2>78</HW2>
<HW3>70</HW3>
<FINAL>82</FINAL>
<GRADE>BB</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2015700001</STUDENT ID>
<STUDENT NAME>Mesut</STUDENT NAME>
<STUDENT SURNAME>GAVGA</STUDENT SURNAME>
<COURSE CODE>CME2204</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>90</MID1>
<MID2>90</MID2>
<HW1>100</HW1>
<HW2>96</HW2>
<HW3>88</HW3>
<FINAL>85</FINAL>
<GRADE>AA</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2016700018</STUDENT ID>
<STUDENT NAME>Merve Rana</STUDENT NAME>
<STUDENT SURNAME>SARI</STUDENT SURNAME>
<COURSE CODE>CME2202</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>0</MID1>
<MID2>0</MID2>
<HW1>0</HW1>
<HW2>0</HW2>
<HW3>0</HW3>
<FINAL>0</FINAL>
<GRADE>D</GRADE>
<STATUS
>Absent </STATUS
>
</students>
<students>
<STUDENT ID>2016700018</STUDENT ID>
<STUDENT NAME>Merve Rana</STUDENT NAME>
<STUDENT SURNAME>SARI</STUDENT SURNAME>
<COURSE CODE>CME2204</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>55</MID1>
<MID2>57</MID2>
<HW1>0</HW1>
<HW2>66</HW2>
<HW3>60</HW3>
<FINAL>48</FINAL>
<GRADE>DC</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2016700018</STUDENT ID>
<STUDENT NAME>Merve Rana</STUDENT NAME>
<STUDENT SURNAME>SARI</STUDENT SURNAME>
<COURSE CODE>CME2206</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>60</MID1>
<MID2>65</MID2>
<HW1>70</HW1>
<HW2>70</HW2>
<HW3>63</HW3>
<FINAL>60</FINAL>
<GRADE>CC</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2015700022</STUDENT ID>
<STUDENT NAME>Nadir</STUDENT NAME>
<STUDENT SURNAME>ÖZCAN</STUDENT SURNAME>
<COURSE CODE>CME2202</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>98</MID1>
<MID2>95</MID2>
<HW1>98</HW1>
<HW2>90</HW2>
<HW3>92</HW3>
<FINAL>85</FINAL>
<GRADE>AA</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2015700022</STUDENT ID>
<STUDENT NAME>Nadir</STUDENT NAME>
<STUDENT SURNAME>ÖZCAN</STUDENT SURNAME>
<COURSE CODE>CME3004</COURSE CODE>
<COURSE CREDIT>4</COURSE CREDIT>
<MID1>85</MID1>
<MID2>90</MID2>
<HW1>88</HW1>
<HW2>90</HW2>
<HW3>00</HW3>
<FINAL>0</FINAL>
</students>
<students>
<STUDENT ID>2015700022</STUDENT ID>
<STUDENT NAME>Nadir</STUDENT NAME>
<STUDENT SURNAME>ÖZCAN</STUDENT SURNAME>
<COURSE CODE>CME2206</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>90</MID1>
<MID2>78</MID2>
<HW1>95</HW1>
<HW2>90</HW2>
<HW3>88</HW3>
<FINAL>92</FINAL>
<GRADE>AA</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2016700019</STUDENT ID>
<STUDENT NAME>Mehmet Emin</STUDENT NAME>
<STUDENT SURNAME>TATLI</STUDENT SURNAME>
<COURSE CODE>CME2204</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>20</MID1>
<MID2>12</MID2>
<HW1>0</HW1>
<HW2>25</HW2>
<HW3>0</HW3>
<FINAL>30</FINAL>
<GRADE>FF</GRADE>
<STATUS
>Failed </STATUS
>
</students>
<students>
<STUDENT ID>2016700019</STUDENT ID>
<STUDENT NAME>Mehmet Emin</STUDENT NAME>
<STUDENT SURNAME>TATLI</STUDENT SURNAME>
<COURSE CODE>CME2206</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>15</MID1>
<MID2>0</MID2>
<HW1>0</HW1>
<HW2>0</HW2>
<HW3>0</HW3>
<FINAL>0</FINAL>
<GRADE>D</GRADE>
<STATUS
>Absent </STATUS
>
</students>
<students>
<STUDENT ID>2015700030</STUDENT ID>
<STUDENT NAME>Ali</STUDENT NAME>
<STUDENT SURNAME>SALMANLI</STUDENT SURNAME>
<COURSE CODE>CME2202</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>82</MID1>
<MID2>77</MID2>
<HW1>100</HW1>
<HW2>98</HW2>
<HW3>100</HW3>
<FINAL>68</FINAL>
<GRADE>BA</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2015700030</STUDENT ID>
<STUDENT NAME>Ali</STUDENT NAME>
<STUDENT SURNAME>SALMANLI</STUDENT SURNAME>
<COURSE CODE>CME3004</COURSE CODE>
<COURSE CREDIT>4</COURSE CREDIT>
<MID1>76</MID1>
<MID2>80</MID2>
<HW1>80</HW1>
<HW2>80</HW2>
<HW3>00</HW3>
<FINAL>0</FINAL>
</students>
<students>
<STUDENT ID>2015700030</STUDENT ID>
<STUDENT NAME>Ali</STUDENT NAME>
<STUDENT SURNAME>SALMANLI</STUDENT SURNAME>
<COURSE CODE>CME3006</COURSE CODE>
<COURSE CREDIT>4</COURSE CREDIT>
<MID1>80</MID1>
<MID2>00</MID2>
<HW1>0</HW1>
</students>
<students>
<STUDENT ID>2015700030</STUDENT ID>
<STUDENT NAME>Ali</STUDENT NAME>
<STUDENT SURNAME>SALMANLI</STUDENT SURNAME>
<COURSE CODE>CME2204</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>90</MID1>
<MID2>94</MID2>
<HW1>95</HW1>
<HW2>90</HW2>
<HW3>88</HW3>
<FINAL>80</FINAL>
<GRADE>AA</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2015700031</STUDENT ID>
<STUDENT NAME>Selin</STUDENT NAME>
<STUDENT SURNAME>BAYTUR</STUDENT SURNAME>
<COURSE CODE>CME2202</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>40</MID1>
<MID2>38</MID2>
<HW1>0</HW1>
<HW2>20</HW2>
<HW3>25</HW3>
<FINAL>26</FINAL>
<GRADE>FF</GRADE>
<STATUS
>Failed </STATUS
>
</students>
<students>
<STUDENT ID>2015700031</STUDENT ID>
<STUDENT NAME>Selin</STUDENT NAME>
<STUDENT SURNAME>BAYTUR</STUDENT SURNAME>
<COURSE CODE>CME3004</COURSE CODE>
<COURSE CREDIT>4</COURSE CREDIT>
<MID1>65</MID1>
<MID2>60</MID2>
<HW1>72</HW1>
<HW2>65</HW2>
<HW3>00</HW3>
<FINAL>0</FINAL>
</students>
<students>
<STUDENT ID>2015700031</STUDENT ID>
<STUDENT NAME>Selin</STUDENT NAME>
<STUDENT SURNAME>BAYTUR</STUDENT SURNAME>
<COURSE CODE>CME2204</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>60</MID1>
<MID2>48</MID2>
<HW1>50</HW1>
<HW2>52</HW2>
<HW3>50</HW3>
<FINAL>60</FINAL>
<GRADE>DC</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2016700020</STUDENT ID>
<STUDENT NAME>Oğulcan</STUDENT NAME>
<STUDENT SURNAME>ÖZARSLAN</STUDENT SURNAME>
<COURSE CODE>CME2202</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>65</MID1>
<MID2>80</MID2>
<HW1>100</HW1>
<HW2>100</HW2>
<HW3>95</HW3>
<FINAL>85</FINAL>
<GRADE>BA</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2016700020</STUDENT ID>
<STUDENT NAME>Oğulcan</STUDENT NAME>
<STUDENT SURNAME>ÖZARSLAN</STUDENT SURNAME>
<COURSE CODE>CME2206</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>86</MID1>
<MID2>88</MID2>
<HW1>90</HW1>
<HW2>90</HW2>
<HW3>100</HW3>
<FINAL>100</FINAL>
<GRADE>AA</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2015700042</STUDENT ID>
<STUDENT NAME>Murat</STUDENT NAME>
<STUDENT SURNAME>GÜREL</STUDENT SURNAME>
<COURSE CODE>CME2204</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>40</MID1>
<MID2>0</MID2>
<HW1>0</HW1>
<HW2>50</HW2>
<HW3>20</HW3>
<FINAL>38</FINAL>
<GRADE>FF</GRADE>
<STATUS
>Failed </STATUS
>
</students>
<students>
<STUDENT ID>2015700042</STUDENT ID>
<STUDENT NAME>Murat</STUDENT NAME>
<STUDENT SURNAME>GÜREL</STUDENT SURNAME>
<COURSE CODE>CME2202</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>71</MID1>
<MID2>63</MID2>
<HW1>65</HW1>
<HW2>74</HW2>
<HW3>70</HW3>
<FINAL>60</FINAL>
<GRADE>CB</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2016700035</STUDENT ID>
<STUDENT NAME>Sercan</STUDENT NAME>
<STUDENT SURNAME>ERGÖRMÜŞ</STUDENT SURNAME>
<COURSE CODE>CME3006</COURSE CODE>
<COURSE CREDIT>4</COURSE CREDIT>
<MID1>100</MID1>
<MID2>00</MID2>
<HW1>0</HW1>
</students>
<students>
<STUDENT ID>2016700036</STUDENT ID>
<STUDENT NAME>Çağla</STUDENT NAME>
<STUDENT SURNAME>PAK</STUDENT SURNAME>
<COURSE CODE>CME3006</COURSE CODE>
<COURSE CREDIT>4</COURSE CREDIT>
<MID1>47</MID1>
<MID2>00</MID2>
<HW1>0</HW1>
</students>
<students>
<STUDENT ID>2016700036</STUDENT ID>
<STUDENT NAME>Çağla</STUDENT NAME>
<STUDENT SURNAME>PAK</STUDENT SURNAME>
<COURSE CODE>CME2206</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>0</MID1>
<MID2>0</MID2>
<HW1>0</HW1>
<HW2>0</HW2>
<HW3>0</HW3>
<FINAL>0</FINAL>
<GRADE>D</GRADE>
<STATUS
>Absent </STATUS
>
</students>
<students>
<STUDENT ID>2016700036</STUDENT ID>
<STUDENT NAME>Çağla</STUDENT NAME>
<STUDENT SURNAME>PAK</STUDENT SURNAME>
<COURSE CODE>CME2204</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>8</MID1>
<MID2>18</MID2>
<HW1>0</HW1>
<HW2>25</HW2>
<HW3>50</HW3>
<FINAL>35</FINAL>
<GRADE>FF</GRADE>
<STATUS
>Failed </STATUS
>
</students>
<students>
<STUDENT ID>2016700037</STUDENT ID>
<STUDENT NAME>Kerim</STUDENT NAME>
<STUDENT SURNAME>KENAR</STUDENT SURNAME>
<COURSE CODE>CME2206</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>70</MID1>
<MID2>75</MID2>
<HW1>80</HW1>
<HW2>80</HW2>
<HW3>72</HW3>
<FINAL>75</FINAL>
<GRADE>BB</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2016700037</STUDENT ID>
<STUDENT NAME>Kerim</STUDENT NAME>
<STUDENT SURNAME>KENAR</STUDENT SURNAME>
<COURSE CODE>CME2204</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>80</MID1>
<MID2>80</MID2>
<HW1>85</HW1>
<HW2>56</HW2>
<HW3>70</HW3>
<FINAL>48</FINAL>
<GRADE>CB</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2016700050</STUDENT ID>
<STUDENT NAME>Eda</STUDENT NAME>
<STUDENT SURNAME>CANSEVER</STUDENT SURNAME>
<COURSE CODE>CME3006</COURSE CODE>
<COURSE CREDIT>4</COURSE CREDIT>
<MID1>45</MID1>
<MID2>00</MID2>
<HW1>0</HW1>
</students>
<students>
<STUDENT ID>2015700081</STUDENT ID>
<STUDENT NAME>Orkun</STUDENT NAME>
<STUDENT SURNAME>TANER</STUDENT SURNAME>
<COURSE CODE>CME2204</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>95</MID1>
<MID2>88</MID2>
<HW1>70</HW1>
<HW2>86</HW2>
<HW3>100</HW3>
<FINAL>75</FINAL>
<GRADE>BA</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2015700081</STUDENT ID>
<STUDENT NAME>Orkun</STUDENT NAME>
<STUDENT SURNAME>TANER</STUDENT SURNAME>
<COURSE CODE>CME2206</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>100</MID1>
<MID2>100</MID2>
<HW1>98</HW1>
<HW2>98</HW2>
<HW3>80</HW3>
<FINAL>100</FINAL>
<GRADE>AA</GRADE>
<STATUS
>Successful </STATUS
>
</students>
<students>
<STUDENT ID>2016700052</STUDENT ID>
<STUDENT NAME>Ceren</STUDENT NAME>
<STUDENT SURNAME>ÖZTÜRK</STUDENT SURNAME>
<COURSE CODE>CME3004</COURSE CODE>
<COURSE CREDIT>4</COURSE CREDIT>
<MID1>50</MID1>
<MID2>0</MID2>
<HW1>65</HW1>
<HW2>40</HW2>
<HW3>00</HW3>
<FINAL>0</FINAL>
</students>
<students>
<STUDENT ID>2015700085</STUDENT ID>
<STUDENT NAME>Tarık</STUDENT NAME>
<STUDENT SURNAME>BABAOĞLU</STUDENT SURNAME>
<COURSE CODE>CME2202</COURSE CODE>
<COURSE CREDIT>3</COURSE CREDIT>
<MID1>0</MID1>
<MID2>0</MID2>
<HW1>0</HW1>
<HW2>0</HW2>
<HW3>0</HW3>
<FINAL>0</FINAL>
<GRADE>D</GRADE>
<STATUS
>Absent </STATUS
>
</students>
</studentInfo>
答案 0 :(得分:1)
1)&#34;搞笑&#34;字符是\r
,它是文件中行尾标记(以及\n
)的一部分。可能最容易将其添加到您拆分线路的列表中。
2)这很可能是因为某些标题会生成无效标签,即&#34;学生ID&#34;。您无法在标记名称中包含空格 - 您应该浏览tags
中的每个字符串,并使用下划线替换所有空格和其他无效字符,或者只删除它们。
3)strsep
没有创建新字符串,只需要buf2
并在其中返回不同的指针。所以你不能strcpy
进入它。而是将检查移动到XML创建中,然后执行
xmlNewChild(node, NULL, BAD_CAST tags[j], BAD_CAST "0");