none
How do I add a condition to my vb.net code? RRS feed

  • Question

  • In the xml document below, I would like to check for 3 things

    1. If Phone/@Current ='true'
    2. If Type/@Word ='HOME'
    3. If Invalid is not true

    I have done 1 and 2 but I am not sure how to do 3 in the same line of code.  

    My xml document which is put into an object objxmlPhoneNode

    <?xml version="1.0" encoding="UTF-8"?><Phone Op="A" Current="true">	<Type Op="A" Word="HOME">Home</Type>	<Number Op="A">444-081-7031</Number>	<Invalid>true</Invalid></Phone>





    I have taken care of condition number 1 and 2. I need hep to add condition 3. i.e. If Invalid is not true. 

    objxmlPhoneNode = objXmlPartyNode.SelectSingleNode("Phone[@Current='true' and Type/@Word='HOME']")

    Wednesday, November 28, 2018 8:25 PM

All replies

  • Hi there,

    You can try the following XPath statement:

    /Phone[@Current='true' and Type/@Word='HOME' and not(Invalid='true')]


    Wednesday, November 28, 2018 9:17 PM
  • Thanks so much. It took some effort without success but you have saved my day/stress.
    Thursday, November 29, 2018 3:10 PM
  • Hi winkimjr2,

    Glad to hear that the proposed solution works for you.

    Please don't forget to mark it as 'Answered'.


    Thursday, November 29, 2018 3:15 PM