c# - Formatting with System.XML -
i redoing legacy vb.net app in mvc. part of app used msxml2 create xml document. having trouble 2 elements far. legacy code uses "right" (right function in c#?) , "format" (equivalent of format of vb in c#) commands.
is there preferred method creating xml other using system.xml?
objnode = objdoc.createnode("element", "payout", ""); objelement = objdoc.documentelement.appendchild(objnode); objelement.setattribute("companynumber", right(objrs.fields["operating_unit_code"].value, 3)); objelement.setattribute("employeenumber", objrs.fields["employee_code"].value); objelement.setattribute("earningscode", objrs.fields["incentive_type_code"].value); objelement.setattribute("chargetoproject", right(objrs.fields["operating_unit_code"].value, 3) & objrs.fields["organization_code"].value); objelement.setattribute("amount", format(objrs.fields["sum_calc_amount"].value, "#.00")); objelement.setattribute("weekendingdate", format(objrs.fields["pay_period_end_date"].value, "mm/dd/yyyy")); objelement.setattribute("employeename", objrs.fields["full_name"].value);
xdocument , linq xml popular way of creating xml. xdocument or xmldocument contains reasons 1 or another.
if porting vb.net code using xmldocument
(or other implementation of xml dom api) easier keep using minimize changes. may away decompiling assembly or particular methods c# code (i.e. using ilspy or r#).
note: msxml2 (or other version) not supported in managed applications, using not option.
Comments
Post a Comment