I need some clarification on the proper usage of XML DOM (and perhaps XML itself) as I'm a bit of a noob when it comes to XML manipulation.
The replaceData is giving strange results. Essentially it will only replace EXISTING data. It will not replace a null value.
I have an XML document that looks like this:
The following code (written in kix but I can duplicate this problem in VBScript as well)...
My resulting XML ends up with fields 1 and 5 having data. The other fields are blank. I've tried appenddata and insert data as well, but that doesn't work.
What should I be doing differently?
The replaceData is giving strange results. Essentially it will only replace EXISTING data. It will not replace a null value.
I have an XML document that looks like this:
Code:
<hwAssetUserField1 type="attrib">67671</hwAssetUserField1> <hwAssetUserField2 type="attrib"></hwAssetUserField2> <hwAssetUserField3 type="attrib"></hwAssetUserField3> <hwAssetUserField4 type="attrib"></hwAssetUserField4> <hwAssetUserField5 type="attrib">34</hwAssetUserField5>
Code:
$XMLFile="Test.xml"
If $xmlDoc.load($XMLFile)
$XMLWriteLen = 9999
$xmlDoc.getElementsByTagName("hwAssetUserField1").Item(0).firstChild.replaceData(0,$XMLWriteLen,"67671")
$xmlDoc.getElementsByTagName("hwAssetUserField2").Item(0).firstChild.replaceData(0,$XMLWriteLen,"72")
$xmlDoc.getElementsByTagName("hwAssetUserField3").Item(0).firstChild.replaceData(0,$XMLWriteLen,"72")
$xmlDoc.getElementsByTagName("hwAssetUserField4").Item(0).firstChild.replaceData(0,$XMLWriteLen,"72")
$xmlDoc.getElementsByTagName("hwAssetUserField5").Item(0).firstChild.replaceData(0,$XMLWriteLen,"72")
$xmlDoc.Save($XMLFile)
What should I be doing differently?
Comment