我正在为我正在进行的项目编写集成测试,但我陷入困境。我有一个对象(让我们称之为travelerDetail),它存储一个表示在航班上预订的座位的对象列表,我想在xml中创建一个具有反映这些座位的属性的travelDetail元素。现在它有点像:
<SEAT DDATE="2012-05-22" TCHG="07:30:10" ROW="11" LETTER="A" POSN="R" SIDE="L" EXIT="N" ID="D164771" CKIN="" ONBORD="" CHGCDE="C" PAGE="1" DCHG="2012-05-22 12:20:44.396" TCHG="16:43:45" PCHG="07272" />
<TRAVELERDETAIL ITN="3224" PDDATE="07:30:10" DOW="4" ORIG="BLI" DEST="LAS" FINALDST="LAS" PTYPE="R" LNAME="SPADE" FNAME="ADULTONE" SFEE1="0.00" SFEE2="0.00" SFEE3="0.00" NOREFUND="" FARE="127.44" COST="0.00" FTAX="9.56" PFC="4.50" FSC="0.00" FEDEX="3.80" SECCHG="2.50" DISCAMT="0.00" ALLOCFARE="127.44" MILES="954" FUELGAL="0.000" FUELRATE="0.000" FUELPRICE="0.00" CNTRY="USA" BOOKTIME="2012-05-22 12:20:44.396" BKCHG="0.00" WAITING="N" TFLT="" BAGS="0" PPBAGS="1" PPFEE="19.99" APBAGS="0" APFEE="0.00" TPFEE="0.00" FREEBAGS="0" DEPART="2012-05-22 12:20:44.396" ARRIVE="2012-05-22 12:20:44.396" GENDER="M" DOB="1970-01-01" DHSSEQ="0" CHGCDE="A" PAGE="0" DCHG="2012-05-22" TCHG="07:30:10" REC_ID="-10"/>
TravelerDetail类维护旅行者可能在航班上预订的座位列表。我可以像这样创建xml测试数据吗?
答案 0 :(得分:2)
IMHO XML属性可以是任何对象的属性......不是对象本身
这可能是您希望xml看起来的样子。
<TRAVELERDETAIL ITN="3224" PDDATE="07:30:10" DOW="4" ORIG="BLI" DEST="LAS" FINALDST="LAS" PTYPE="R" LNAME="SPADE" FNAME="ADULTONE" SFEE1="0.00" SFEE2="0.00" SFEE3="0.00" NOREFUND="" FARE="127.44" COST="0.00" FTAX="9.56" PFC="4.50" FSC="0.00" FEDEX="3.80" SECCHG="2.50" DISCAMT="0.00" ALLOCFARE="127.44" MILES="954" FUELGAL="0.000" FUELRATE="0.000" FUELPRICE="0.00" CNTRY="USA" BOOKTIME="2012-05-22 12:20:44.396" BKCHG="0.00" WAITING="N" TFLT="" BAGS="0" PPBAGS="1" PPFEE="19.99" APBAGS="0" APFEE="0.00" TPFEE="0.00" FREEBAGS="0" DEPART="2012-05-22 12:20:44.396" ARRIVE="2012-05-22 12:20:44.396" GENDER="M" DOB="1970-01-01" DHSSEQ="0" CHGCDE="A" PAGE="0" DCHG="2012-05-22" TCHG="07:30:10" REC_ID="-10">
<SEAT DDATE="2012-05-22" TCHG="07:30:10" ROW="11" LETTER="A" POSN="R" SIDE="L" EXIT="N" ID="D164771" CKIN="" ONBORD="" CHGCDE="C" PAGE="1" DCHG="2012-05-22 12:20:44.396" TCHG="16:43:45" PCHG="07272"/>
<SEAT /> ...
</TRAVELERDETAIL>
当然,您可以将任意数量的座位分配给您的TRAVELERDETAIL,因为它是由行程识别的
答案 1 :(得分:0)
您可以嵌套XML元素。
<TRAVELERDETAIL>
<SEAT />
<SEAT />
</TRAVELERDETAIL>