Bran-Damage
asked on
Trying to add XElements to my existing XML
Here is my XML:
<PWCScript Version="2011113">
<Table Name="QD" Action="Edit">
<Choose Name="QD_JOB_NUM" Value="10244" />
<Choose Name="QD_DES_SEQ" Value="1" />
<Update Name="QD_DELIV_DATE" Value="01010001" />
<Update Name="QD_DELIV_METH" Value="UPS Blue" />
<Update Name="QD_CONSIGN" Value="571081ce-2c62-46f1- b21a-68ad7 b52a984" />
<Update Name="QD_FREIGHT_COST" Value="10.18" />
<Update Name="QD_PACK_NUM" Value="10244:1" />
<Update Name="QD_DES_QTY" Value="500" />
<Update Name="QD_PART_FINAL" Value="QDG_PARTIAL_NONREPR EDESP" />
</Table>
</PWCScript>
I am trying to do this:
xeShipmentXML.Element("PWC Script").E lement("Ta ble").Add( CreatePack ageXML(ec) );
I get an object reference error.
I do a quick watch to see what is causing it:
?xeShipmentXML.Element("PW CScript")
That is returning Null.
I can't seem to figure out what I am doing wrong. Any help would be appreciated.
Thanks,
Brandon
<PWCScript Version="2011113">
<Table Name="QD" Action="Edit">
<Choose Name="QD_JOB_NUM" Value="10244" />
<Choose Name="QD_DES_SEQ" Value="1" />
<Update Name="QD_DELIV_DATE" Value="01010001" />
<Update Name="QD_DELIV_METH" Value="UPS Blue" />
<Update Name="QD_CONSIGN" Value="571081ce-2c62-46f1-
<Update Name="QD_FREIGHT_COST" Value="10.18" />
<Update Name="QD_PACK_NUM" Value="10244:1" />
<Update Name="QD_DES_QTY" Value="500" />
<Update Name="QD_PART_FINAL" Value="QDG_PARTIAL_NONREPR
</Table>
</PWCScript>
I am trying to do this:
xeShipmentXML.Element("PWC
I get an object reference error.
I do a quick watch to see what is causing it:
?xeShipmentXML.Element("PW
That is returning Null.
I can't seem to figure out what I am doing wrong. Any help would be appreciated.
Thanks,
Brandon
ASKER
I'm not really seeing the solution for the problem that I am running into. I have multiple elements with multiple attributes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes as that is the root node.
Hi
You can do this in two ways
if "ec" is an XElement then you write
xeShipmentXML.Add(ec));
if "ec" is an XML string then you need to write
xeShipmentXML.Add(XElement .Parse(ec) );
.net handle all arrange the elements
Thanks
You can do this in two ways
if "ec" is an XElement then you write
xeShipmentXML.Add(ec));
if "ec" is an XML string then you need to write
xeShipmentXML.Add(XElement
.net handle all arrange the elements
Thanks
ASKER
I figured out my own answer.
http://stackoverflow.com/questions/2131061/how-do-i-insert-an-element-into-xml-using-linq