xPath query attributes in a list

Questions about XML that are not covered by the other forums should go here.
Posts: 4
Joined: Tue Feb 18, 2020 5:29 pm

xPath query attributes in a list

Post by gg7aph » Wed Jun 24, 2020 10:47 pm

Hello, How would I get the @text attribute for each <ListItem> in the below?

Code: Select all

                    <Control id="108" defaultfieldname="purpose" controltype="Control1x2" styleid="0" readonly="False" required="False" skiponedit="False">
                      <Labels title="Purpose" description="purpose" />
                      <Input type="List" allowdecimals="False" formvalueproviderid="0">
                        <List serviceid="0" layerindex="0" fieldname="" multiselect="False">
                            <ListItem text="Routine" value="Routine" />
                            <ListItem text="Dead End" value="Dead End" />
                            <ListItem text="Disinfection" value="Disinfection" />
                            <ListItem text="Water Quality" value="Water Quality" />
                            <ListItem text="System" value="System" />
                      <Value text="" textformatid="0" valueformatid="0" codedvaluedisplay="Name" />
                      <Targets />
                      <Dependencies />
                      <Validations />
I can use the following xPath query to get as far as concatenating the title, defaultfieldname and type. If the type = list then it has child elements I need to include.

Code: Select all

string-join(//AssetLayers/AssetLayer/Forms//Control/(concat(Labels/@title, ',',@defaultfieldname,',', Input/@type,List)), "&#10;")

Posts: 2650
Joined: Tue May 17, 2005 4:01 pm

Re: xPath query attributes in a list

Post by adrian » Thu Jun 25, 2020 5:09 pm


In the context of Control, instead of "Input/@type,List", use:

Code: Select all

Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

Post Reply