XML ファイルのサンプルがあります。ここで、私が持っている SQL テーブル データを使用してオリジナルの XML を生成したいと考えています。
サンプル XML は次のようになります。
<?xml version="1.0"?>
<EmployeeSet xmlns=" http://www.example.com/Employee.xsd " xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DefaultDeptt xsi:nil="true"/>
<Report>
<Report Title="Yearly" Number="S678">
<Status>Current</Status>
<Deptt xsi:nil="true"/>
<Employee LastName="Name" FirstName="Simple" EMail="simple@organization.org" Login="simple"/>
<Location>Builiding 1</Location>
<SubmissionDate xsi:nil="true"/>
<ReportStartDate>2011-05-05</ReportStartDate>
<ReportFinishDate xsi:nil="true"/>
<ReportExpirationDate>2014-05-05</ReportExpirationDate>
<RenewalDate xsi:nil="true"/>
<Records>
<RecordsInfo Name="Paper">
<UsageRecords AnnualUse="5o0" Purpose="printing"/>
</RecordInfo>
</Record>
<Staff/>
</Report>
データを取得しているテーブルの構造は次のとおりです。
- レポートタイトル
- 番号
- 状態
- 苗字
- ファーストネーム
- Eメール
- ログインID
- 位置
- 提出日
- 開始日
- 終了日
- 更新日
- 名前
- 年次使用
- 目的
私は自分の手を試してみましたが、次のようになりました:
<EmployeeSet xmlns="http://www.example.com/Employee.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DefaultDeptt xsi:nil="true"></DefaultDeptt>
<report_title>TESTINGNEW</report_TITLE>
<NUMBER>AC10006</NUMBER>
<STATUS>Approved</STATUS>
<LAST_NAME>XYZ</LAST_NAME>
<FIRST_NAME>ABC</PI_FIRST_NAME>
<EMAIL>ABC.XYZ@gmail.com</EMAIL>
<LOGIN_ID>ABCXYZ</LOGIN_ID>
<LOCATION> </ LOCATION>
<SUBMISSION_DATE>2013-03-25</SUBMISSION_DATE> <START_DATE>2013-03-25</START_DATE>
<FINISH_DATE>2013-03-25</FINISH_DATE>
<RENEWAL_DATE>2014-01-9</RENEWAL_DATE>
<NAME>PAPER</NAME>
<ANNUAL_USE>670</ANNUAL_USE>
<PURPOSE> PRINTING</PURPOSE>
</EmployeeSet>