*simple* Xpath question - InfoPath Dev
in

InfoPath Dev

*simple* Xpath question

Last post 06-22-2007 06:11 AM by davidair. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-22-2007 05:53 AM

    *simple* Xpath question

    Hello All,

    This is going to sound silly but i can't get the xpath right for this. I want to find the first node whose value is blank. Here is the xpath that i use:

     XPathNavigator blankNavigator = formControl1.XmlForm.MainDataSource.CreateNavigator( ).SelectSingleNode( "/my:myFields/my:Survey/my:Inspection/my:InspectedAssets/my:InspectedAsset/my:ass_ID[text()=''] ", NamespaceManager);

    this returns a null node although i know that there is a node in the xml that has an empty value, i just want to grab that one so i can do some stuff with it... does anyone know how to do this? 

     

  • 06-22-2007 06:11 AM In reply to

    Re: *simple* Xpath question

    My biggest recommendation when debugging xpaths that are supposed to work but return null is to put a breakpoint in the debugger and try to run your xpath incrementally, removing pieces from the right until it starts to return something. Then examine the resulting navigator/node/what-have-you in the watch window and try to figure out what is missing.

    For your particular case, I *believe* that when you have an empty value in InfoPath, it actually removes the #text node instead of setting its value to ''. So in your case you will want to replace this:

    /my:ass_ID[text()='']

    with this:

    /my:ass_ID[.='']

    Then it should work.

    David Airapetyan / Software Services Architect
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.