case: “NonEmpty”
<ns0:People>
<ns0:Name>Name_0</ns0:Name>
<ns0:IsDependent>IsDependent_0</ns0:IsDependent>
..
case: “Empty”
<ns0:People>
<ns0:Name></ns0:Name>
<ns0:IsDependent>IsDependent_0</ns0:IsDependent>
..
case: “OneTag”
<ns0:People>
<ns0:Name/>
<ns0:IsDependent>IsDependent_0</ns0:IsDependent>
..
case: “Null”
<ns0:People>
<!– NO NODE: <ns0:Name>Name_0</ns0:Name>–>
<ns0:IsDependent>IsDependent_0</ns0:IsDependent>
..
There is no informationinto theMSDN about this [http://msdn.microsoft.com/en-us/library/aa561906(BTS.10).aspx]
I tried to use the xpath() function in two variants, one with “string(xpath_expression)” second with “xpath_expression”
if ( xpath (msg_SourceRoot, “string(/*[local-name()=’Root’ and namespace-uri()=’http://MapTest.IncPerson’]/*[local-name()=’People’ and namespace-uri()=’http://MapTest.IncPerson’]/*[local-name()=’Name’ and namespace-uri()=’http://MapTest.IncPerson’])”) == null)
{ System.Diagnostics.Trace.WriteLine(“Name == null”); }
{ System.Diagnostics.Trace.WriteLine(“Name == Empty”);}
{ System.Diagnostics.Trace.WriteLine(“Name != null && Name != Empty”); }
System.Diagnostics.Trace.WriteLine(“[” + System.Convert.ToString(xpath (msg_SourceRoot, “/*[local-name()=’Root’ and namespace-uri()=’http://MapTest.IncPerson’]/*[local-name()=’People’ and namespace-uri()=’http://MapTest.IncPerson’]/*[local-name()=’Name’ and namespace-uri()=’http://MapTest.IncPerson’]”)) + “]”);
if ( xpath (msg_SourceRoot, “/*[local-name()=’Root’ and namespace-uri()=’http://MapTest.IncPerson’]/*[local-name()=’People’ and namespace-uri()=’http://MapTest.IncPerson’]/*[local-name()=’Name’ and namespace-uri()=’http://MapTest.IncPerson’]”) == null)
{ System.Diagnostics.Trace.WriteLine(“Name == null”); }
{ System.Diagnostics.Trace.WriteLine(“Name == Empty”); }
{ System.Diagnostics.Trace.WriteLine(“Name != null && Name != Empty”);}
I.e. in thefirs section used the “string(xpath_expression)” expression, in thesecond used the”xpath_expression”
Result is:
“NonEmpty” ======================================================================
[Name_0]
Name != null && Name != Empty
———————————————————————-
[Microsoft.XLANGs.Core.Part+ArrayBasedXmlNodeList]
Name != null && Name != Empty
“Empty”======================================================================
[]
Name == Empty
———————————————————————-
[Microsoft.XLANGs.Core.Part+ArrayBasedXmlNodeList]
Name != null && Name != Empty
“OneTag”======================================================================
[]
Name == Empty
———————————————————————-
[Microsoft.XLANGs.Core.Part+ArrayBasedXmlNodeList]
Name != null && Name != Empty
“Null”======================================================================
[]
Name == Empty
———————————————————————-
[]
Name == null
* “Null” case does not throw an exception.