D
darrel
I have a function that I pass some variables to, that then goes into an XML
file and returns some other values:
dim expr as System.Xml.XPath.XPathExpression = xpn.Compile("//" &
variableToReturn & "[../pageID = '" & pageID & "']")
dim ni as System.Xml.XPath.XPathNodeIterator = xpn.Select(expr)
ni.MoveNext()
if ni.Current.Value <> "" then
valueToReturn = ni.Current.Value
else
valueToReturn = "null"
end if
return valueToReturn
So, I'm passing one string 'variableToReturn' which chooses the node to
grab, and 'pageID' which tell it from which parent node to grab tge
variableToReturn.
This works just fine when I pass a pageID that exists in the XML file:
//contentID[../3]
That will return the value of 'contentID' from the node that also has a
pageID = 3.
The problem is when a pageID value is passed that doesn't exist in the XML
file. Instead of returning nothing, it grabs every single value of every
single node and appends it into this gigantic string. (example: 702nd
HomeHomeFalsenoneFalse087DepartmentsDivisionsFalsenoneTrue1 )
It appears that my expression isn't maybe doing a proper error check to
first see if the node even exists and isntead just grabs everything. Anyone
see a fix for this? Is it a more sophisicated expression?
-Darrel
file and returns some other values:
dim expr as System.Xml.XPath.XPathExpression = xpn.Compile("//" &
variableToReturn & "[../pageID = '" & pageID & "']")
dim ni as System.Xml.XPath.XPathNodeIterator = xpn.Select(expr)
ni.MoveNext()
if ni.Current.Value <> "" then
valueToReturn = ni.Current.Value
else
valueToReturn = "null"
end if
return valueToReturn
So, I'm passing one string 'variableToReturn' which chooses the node to
grab, and 'pageID' which tell it from which parent node to grab tge
variableToReturn.
This works just fine when I pass a pageID that exists in the XML file:
//contentID[../3]
That will return the value of 'contentID' from the node that also has a
pageID = 3.
The problem is when a pageID value is passed that doesn't exist in the XML
file. Instead of returning nothing, it grabs every single value of every
single node and appends it into this gigantic string. (example: 702nd
HomeHomeFalsenoneFalse087DepartmentsDivisionsFalsenoneTrue1 )
It appears that my expression isn't maybe doing a proper error check to
first see if the node even exists and isntead just grabs everything. Anyone
see a fix for this? Is it a more sophisicated expression?
-Darrel