locked
How to use XPATH with XML Data Source RRS feed

  • Question

  • User-72198832 posted

    Have XML Data as shown Below:

    <Inventory_List>
    <Inventory Stock_No="A-1-1" Description="Something" Class="ER" />
    <Inventory Stock_No="A-1-2" Description="Something New" Class="ER" />
    <Inventory Stock_No="B-1-2" Description="Someone New" Class="PQ" />
    </inventory_list>
    
    

    How do I write Xpath statement to find Class="ER" AND Description Contains "NEW"?

    I've tried the following and get "Namespace Manager or Xslt Context needed" Error - What do I need to make this work??

    If I run just XmlDataSource1.Xpath="/Inventory_List/Inventory[@Class='ER']  then that part works correctly - just can't get past error with 'Contains' function either by itself or with the AND operator.

    XmlDataSource1.Xpath="/Inventory_List/Inventory[@Class='ER'] and /Inventory_List/Inventory[contains (@Description ,'New')]"

    Could use some help on this !

    Thanks.

    LB

    Monday, March 2, 2020 6:11 AM

All replies

  • User1535942433 posted

    Hi TRIMS30,

    Accroding to your description,I suggest you could put multiple attributes in the same [].Beside,you could use contains().

    More details,you could refer to below codes:

    XmlDataSource1.XPath="/Inventory_List/Inventory[@Class='ER' and contains(@Description,'New')]"

    Best regards,

    Yijing Sun

    Tuesday, March 3, 2020 6:08 AM
  • User-72198832 posted

    Thanks - tried that but still get error "Namespace Manager or XsltContext needed"

    What extra code do I need? 

    Lee

    Tuesday, March 3, 2020 2:22 PM
  • User1535942433 posted

    Hi TRIMS30,

    Accroding to your description,since you haven't post your codes,as far as I think,you could pass namespacemanager as a parameter to the selectNodes method.

    I suggest you could post your current code to us.It will help us solve your problem.

    More details, you could refer to below article:

    https://forums.asp.net/t/1744543.aspx?Namespace+Manager+or+XsltContext+needed+This+query+has+a+prefix+variable+or+user+defined+function+

    Best regards,

    Yijing Sun

    Wednesday, March 4, 2020 8:48 AM
  • User-72198832 posted

    Problem fixed - had some JavaScript attached to DropDownList that was bound to my XLS table.

    Removed that Script and al is working now.

    Thanks,

    Lee

    Wednesday, March 4, 2020 8:02 PM