How to Query XML File in InfoPath With XPath, Filtering on my:FieldName - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How to Query XML File in InfoPath With XPath, Filtering on my:FieldName

Last post 06-22-2011 02:28 PM by Hilary Stoupa. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 03-29-2011 10:06 AM

    • RKEMN2
    • Not Ranked
    • Joined on 03-25-2011
    • Posts 9

    How to Query XML File in InfoPath With XPath, Filtering on my:FieldName

    Using InfoPath 2010, I want to retrieve a value from an xml file based on the value of a field in my InfoPath form. I'm using this queried value to set a field value using a Rule on Form Load.

    This hard-coded XPath retrieves the desired value:
    xdXDocument:GetDOM("XmlFileName")//GroupB/NodeWithTextValue[@AttributeX='DDD']

    In the above XPath string, I'd like to use form field values for 'GroupB' & 'DDD'

    Assigning just one value in the path with a form field, this validates using the Verify Formula, but does not set the field value as before:
    xdXDocument:GetDOM("XmlFileName")//my:FieldName1/NodeWithTextValue[@AttributeX='DDD']

    This also does not work:
    xdXDocument:GetDOM("XmlFileName")/RootNode/*[. = xdXDocument:get-DOM()/my:myFields/my:FieldName1]

    I've tried several things using the InfoPath function UI to generate the XPath syntax with this filter on a form field, but no success.
    Please suggest an XPath syntax that would accomplish this or the steps using the UI to accomplish this.
    Thanks

    XML structure:
    <RootNode>
      <GroupA>
        <NodeWithTextValue AttributeX="GGG">ValueA1</NodeWithTextValue>
        <NodeWithTextValue AttributeX="HHH">ValueA2</NodeWithTextValue>
      </GroupA>
      <GroupB>
        <NodeWithTextValue AttributeX="FFF">ValueB1</NodeWithTextValue>
        <NodeWithTextValue AttributeX="DDD">ValueB2</NodeWithTextValue>
      </GroupB>
      <GroupC>
        ...

    </RootNode>

  • 04-20-2011 04:25 AM In reply to

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    Re: How to Query XML File in InfoPath With XPath, Filtering on my:FieldName

    Hm. interesting proposal. Don't really know why you would need to do this though.

    But I love a bit of fiddle for fiddles sake.

    Working example attached! :-)

     

    Gonna explain why you need this generic/dynamic query method?

  • 06-22-2011 11:52 AM In reply to

    Re: How to Query XML File in InfoPath With XPath, Filtering on my:FieldName

    Skarn - cannot open your attachment - Error: "This form cannot be opened because it requires the domain permission level and it currently has restricted permission.  To fix this problem, open the form from the location it was published to."

     It then give the published location as a folder on your c-drive.

  • 06-22-2011 11:55 AM In reply to

    Re: How to Query XML File in InfoPath With XPath, Filtering on my:FieldName

    Skarn - more on the error message: Forms that require the domain permission level contain features that access information on a network, such as data connections, linked images, and code.

  • 06-22-2011 12:04 PM In reply to

    Re: How to Query XML File in InfoPath With XPath, Filtering on my:FieldName

    You can't just open a template that has been moved. Save it locally, right click it, and open it in design mode. From there you can resave it and it will recover from its current confusion.

    Hilary Stoupa

  • 06-22-2011 01:02 PM In reply to

    Re: How to Query XML File in InfoPath With XPath, Filtering on my:FieldName

    Thanks.  That worked.  For the record, I had saved it locally and double clicked on the file and got the error message.  I'm in my first week of working in InfoPath and feeling my way.

  • 06-22-2011 02:28 PM In reply to

    Re: How to Query XML File in InfoPath With XPath, Filtering on my:FieldName

    Opening in design after moving is not the most intuitive thing - I mean, you don't have to open an Excel or Word file in a different, special fashion after moving. :-}

    Hilary Stoupa

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.