我能够将csv转换为XML。我的问题是我需要将其转换为格式良好的XML(嵌套XML)。我还需要更改元素名称。任何人都可以指出我正确的方向。
我的平面XML文件
<?xml version="1.0"?>
<data>
<row>
<canName>Victor</canName>
<canID>ABC07</canID>
<courseName>Basic English</courseName>
<canScore>91%</canScore>
<place>School</place>
<examDate>January 01, 2015</examDate>
<title>Mr.</title>
<canTeacher>John</canTeacher>
<tId>GD5</tId>
</row>
<row>
<canName>Victor</canName>
<canID>ABC07</canID>
<courseName>Advanced English</courseName>
<canScore>95%</canScore>
<place>School</place>
<examDate>January 01, 2015</examDate>
<title>Mr.</title>
<canTeacher>John</canTeacher>
<tId>GD5</tId>
</row>
<row>
<canName>Tia</canName>
<canID>ABC01</canID>
<courseName>Basic English</courseName>
<canScore>90%</canScore>
<place>School</place>
<examDate>January 01, 2015</examDate>
<title>Mr.</title>
<canTeacher>John</canTeacher>
<tId>GD5</tId>
</row>
</data>
我想将其转换为以下嵌套XML文件
<?xml version="1.0"?>
<candidates>
<candidate canName="Victor" canID="ABC07">
<course courseName="Basic English">
<score>91%</score>
<place>School</place>
<examDate>January 01, 2015</examDate>
<title>Mr.</title>
<canTeacher>John</canTeacher>
<tID>GD5</tID>
</course>
<course courseName="Advanced English">
<score>95%</score>
<place>School</place>
<examDate>January 01, 2015</examDate>
<title>Mr.</title>
<canTeacher>John</canTeacher>
<tID>GD5</tID>
</course>
</candidate>
<candidate canName="Tia" userID="ABC01">
<course courseName="Basic English">
<score>90%</score>
<place>School</place>
<examDate>January 01, 2015</examDate>
<title>Mr.</title>
<canTeacher>John</canTeacher>
<tID>GD5</tID>
</course>
<course courseName="Advanced English">
<score>92%</score>
<place>School</place>
<examDate>January 01, 2015</examDate>
<title>Mr.</title>
<canTeacher>John</canTeacher>
<tID>GD5</tID>
</course>
</candidate>
</candidates>