EDN Admin
Well-known member
Hi, all. Just getting back into using VB.NET after doing it several years ago when it first hit the streets. I am simply attempting to select and remove a child node from an XML document and having a heck of a time using SelectSingleNode to pick
up the one I want (the "XOGOutput" tag, which can only appear once in this output). It keeps coming up NULL. Anyone have any ideas what I might be doing wrong?
Code:
Dim oInput = New System.Xml.XmlDocument<br/>
oInput.Load("Croject_read_ii.xml")<br/>
Dim oNav As System.Xml.XPath.XPathNavigator<br/>
oNav = oInput.CreateNavigator()<br/>
oNav = oNav.SelectSingleNode("XOGOutput")<br/>
oNav.DeleteSelf()
XML (from the file project_read_ii.xml):
<NikuDataBus><br/>
<Header externalSource="NIKU" version="13.0.0.7032" /><br/>
<Projects><br/>
<Project active="true" alignment="78" approved="true" approvedForBilling="1" asOf="2012-08-07T00:00:00" assgnPool="0" billingCurrencyCode="USD" billingType="S" budgetBreakEven="2012-02-01T00:00:00" budgetCostFinish="2012-09-01T00:00:00"
budgetCostStart="2011-11-01T00:00:00" budgetCostTotal="439999.598012" budgetIRR="1.074212" budgetMIRR="0.264337" budgetNPV="662970.852426" budgetPaybackPeriod="3" budgetROI="1.536155" budgetRevFinish="2012-07-01T00:00:00" budgetRevStart="2011-12-01T00:00:00"
budgetRevTotal="1120000" calculateFinancialMetrics="true" cbkType="INVESTMENT" chargeCodeExtID="Expense" closed="false" currencyISOcode="USD" entityCode="Corporate" equipmentCostSource="Financial Cost and Rate Matrix" equipmentExchageRateType="AVERAGE" equipmentRateSource="Financial
Cost and Rate Matrix" evCalcMethod="0" expenseCostSource="Financial Cost and Rate Matrix" expenseExchageRateType="AVERAGE" expenseRateSource="Financial Cost and Rate Matrix" financialProjectClass="INTERNAL" financialStatus="O" financialWipClass="INTERNAL"
finish="2012-08-06T17:00:00" flexibilityRisk="0" format="0" fundingRisk="0" goalCode="REDUCE_COST" humanInterfaceRisk="0" implementationRisk="0" interdependenciesRisk="0" laborCostSource="Financial Cost and Rate Matrix" laborExchageRateType="AVERAGE" laborRateSource="Financial
Cost and Rate Matrix" lastUpdatedBy="admin" lastUpdatedDate="2012-05-17T19:29:55" managerResourceID="paulMartin" materialCostSource="Financial Cost and Rate Matrix" materialExchageRateType="AVERAGE" materialRateSource="Financial Cost and Rate Matrix" name="eCommerce
Portal" objectivesRisk="0" openForTimeEntry="true" organizationalCultureRisk="0" pageLayoutCode="dashPrjStatus" percentCalcMode="0" percentComplete="0" plannedBenFinish="2012-08-01T00:00:00" plannedBenStart="2012-04-01T00:00:00" plannedBenTotal="600000" plannedBreakEven="2012-07-01T00:00:00"
plannedCostFinish="2012-09-01T00:00:00" plannedCostStart="2011-11-01T00:00:00" plannedCostTotal="476100.001521" plannedIRR="0.088152" plannedMIRR="0.042281" plannedNPV="115239.658329" plannedPaybackPeriod="8" plannedROI="0.247113" priority="33" processCode="IT"
progress="0" projectID="PR1002" requiredForScenarios="false" resourceAvailabilityRisk="0" setBudgetValuesEqualToPlannedValues="false" sponsorshipRisk="50" stageCode="Building" start="2011-11-02T08:00:00" status="1" statusIndicator="1" supportabilityRisk="0"
syncInvestmentAndBudgetDates="true" technicalRisk="0" template="false" trackMode="2" useSystemDefinedReinvestmentRate="true" useSystemDefinedTotalCostOfCapital="true <br/>
<scenarioDependencies><br/>
<scenarioDependency name="Financial Workflow Development" objectInstanceCode="PR1019" objectType="PROJECT" /><br/>
</scenarioDependencies><br/>
<InvestmentAssociations><br/>
<Allocations /><br/>
<Hierarchies /><br/>
</InvestmentAssociations><br/>
<General addedBy="admin" addedDate="2007-01-31" /><br/>
<OBSAssocs complete="false <br/>
<OBSAssoc id="corpDepartmentOBS" name="Corporate Department OBS" unitPath="/IT" /><br/>
<OBSAssoc id="corpLocationOBS" name="Corporate Location OBS" unitPath="/New York" /><br/>
<OBSAssoc id="Organizational" name="Organizational" unitPath="/All LOBs/Online Order Management" /><br/>
</OBSAssocs><br/>
</Project><br/>
</Projects><br/>
<XOGOutput><br/>
<Object type="project" /><br/>
<Status state="SUCCESS" /><br/>
<Statistics failureRecords="0" insertedRecords="0" totalNumberOfRecords="1" updatedRecords="0" /><br/>
<Records><br/>
<Record><br/>
<KeyInformation><br/>
<column name="object_code project</column><br/>
</KeyInformation><br/>
<ErrorInformation><br/>
<Severity>WARNING</Severity><br/>
<Description>XOG-9101: Document Location not specified, attachments not exported</Description><br/>
</ErrorInformation><br/>
</Record><br/>
</Records><br/>
<DeprecationInformation><br/>
<Severity>WARNING</Severity><br/>
<Description>DEPRECATION MESSAGE</Description><br/>
<Exception type="java.lang.Exception The action and objectType attributes in the Header have been deprecated.</Exception><br/>
</DeprecationInformation><br/>
</XOGOutput><br/>
</NikuDataBus>
View the full article
up the one I want (the "XOGOutput" tag, which can only appear once in this output). It keeps coming up NULL. Anyone have any ideas what I might be doing wrong?
Code:
Dim oInput = New System.Xml.XmlDocument<br/>
oInput.Load("Croject_read_ii.xml")<br/>
Dim oNav As System.Xml.XPath.XPathNavigator<br/>
oNav = oInput.CreateNavigator()<br/>
oNav = oNav.SelectSingleNode("XOGOutput")<br/>
oNav.DeleteSelf()
XML (from the file project_read_ii.xml):
<NikuDataBus><br/>
<Header externalSource="NIKU" version="13.0.0.7032" /><br/>
<Projects><br/>
<Project active="true" alignment="78" approved="true" approvedForBilling="1" asOf="2012-08-07T00:00:00" assgnPool="0" billingCurrencyCode="USD" billingType="S" budgetBreakEven="2012-02-01T00:00:00" budgetCostFinish="2012-09-01T00:00:00"
budgetCostStart="2011-11-01T00:00:00" budgetCostTotal="439999.598012" budgetIRR="1.074212" budgetMIRR="0.264337" budgetNPV="662970.852426" budgetPaybackPeriod="3" budgetROI="1.536155" budgetRevFinish="2012-07-01T00:00:00" budgetRevStart="2011-12-01T00:00:00"
budgetRevTotal="1120000" calculateFinancialMetrics="true" cbkType="INVESTMENT" chargeCodeExtID="Expense" closed="false" currencyISOcode="USD" entityCode="Corporate" equipmentCostSource="Financial Cost and Rate Matrix" equipmentExchageRateType="AVERAGE" equipmentRateSource="Financial
Cost and Rate Matrix" evCalcMethod="0" expenseCostSource="Financial Cost and Rate Matrix" expenseExchageRateType="AVERAGE" expenseRateSource="Financial Cost and Rate Matrix" financialProjectClass="INTERNAL" financialStatus="O" financialWipClass="INTERNAL"
finish="2012-08-06T17:00:00" flexibilityRisk="0" format="0" fundingRisk="0" goalCode="REDUCE_COST" humanInterfaceRisk="0" implementationRisk="0" interdependenciesRisk="0" laborCostSource="Financial Cost and Rate Matrix" laborExchageRateType="AVERAGE" laborRateSource="Financial
Cost and Rate Matrix" lastUpdatedBy="admin" lastUpdatedDate="2012-05-17T19:29:55" managerResourceID="paulMartin" materialCostSource="Financial Cost and Rate Matrix" materialExchageRateType="AVERAGE" materialRateSource="Financial Cost and Rate Matrix" name="eCommerce
Portal" objectivesRisk="0" openForTimeEntry="true" organizationalCultureRisk="0" pageLayoutCode="dashPrjStatus" percentCalcMode="0" percentComplete="0" plannedBenFinish="2012-08-01T00:00:00" plannedBenStart="2012-04-01T00:00:00" plannedBenTotal="600000" plannedBreakEven="2012-07-01T00:00:00"
plannedCostFinish="2012-09-01T00:00:00" plannedCostStart="2011-11-01T00:00:00" plannedCostTotal="476100.001521" plannedIRR="0.088152" plannedMIRR="0.042281" plannedNPV="115239.658329" plannedPaybackPeriod="8" plannedROI="0.247113" priority="33" processCode="IT"
progress="0" projectID="PR1002" requiredForScenarios="false" resourceAvailabilityRisk="0" setBudgetValuesEqualToPlannedValues="false" sponsorshipRisk="50" stageCode="Building" start="2011-11-02T08:00:00" status="1" statusIndicator="1" supportabilityRisk="0"
syncInvestmentAndBudgetDates="true" technicalRisk="0" template="false" trackMode="2" useSystemDefinedReinvestmentRate="true" useSystemDefinedTotalCostOfCapital="true <br/>
<scenarioDependencies><br/>
<scenarioDependency name="Financial Workflow Development" objectInstanceCode="PR1019" objectType="PROJECT" /><br/>
</scenarioDependencies><br/>
<InvestmentAssociations><br/>
<Allocations /><br/>
<Hierarchies /><br/>
</InvestmentAssociations><br/>
<General addedBy="admin" addedDate="2007-01-31" /><br/>
<OBSAssocs complete="false <br/>
<OBSAssoc id="corpDepartmentOBS" name="Corporate Department OBS" unitPath="/IT" /><br/>
<OBSAssoc id="corpLocationOBS" name="Corporate Location OBS" unitPath="/New York" /><br/>
<OBSAssoc id="Organizational" name="Organizational" unitPath="/All LOBs/Online Order Management" /><br/>
</OBSAssocs><br/>
</Project><br/>
</Projects><br/>
<XOGOutput><br/>
<Object type="project" /><br/>
<Status state="SUCCESS" /><br/>
<Statistics failureRecords="0" insertedRecords="0" totalNumberOfRecords="1" updatedRecords="0" /><br/>
<Records><br/>
<Record><br/>
<KeyInformation><br/>
<column name="object_code project</column><br/>
</KeyInformation><br/>
<ErrorInformation><br/>
<Severity>WARNING</Severity><br/>
<Description>XOG-9101: Document Location not specified, attachments not exported</Description><br/>
</ErrorInformation><br/>
</Record><br/>
</Records><br/>
<DeprecationInformation><br/>
<Severity>WARNING</Severity><br/>
<Description>DEPRECATION MESSAGE</Description><br/>
<Exception type="java.lang.Exception The action and objectType attributes in the Header have been deprecated.</Exception><br/>
</DeprecationInformation><br/>
</XOGOutput><br/>
</NikuDataBus>
View the full article