Page 1 of 1

Grab the correct field in XML file

Posted: Tue Nov 12, 2024 6:08 pm
by jdr_cbp_1953
I have a web to print solution that provides me with an XML file with every job ticket. When the job tickets were created, some questions are universal across order forms, items such as "job name", "due date", "quantity", "is a proof required", etc. The problem is that they are not always in the same order on each form's XML file. In my example, I have an XML file for my posters order form and an XML file from my flyers order form. I'm looking for the saved value for udf_Proof:

<JobItemField>
<ID>udf_Proof</ID>
<Type>D</Type>
<Prompt>Proof Requested?</Prompt>
<Value>None Printed Proof Online Proof</Value>
SavedValue>Printed Proof</SavedValue>

In the order form for posters, the XML location path according to switch is:
/Job/Items/JobItem/Fields/JobItemField[79]

In the order for flyers, the XML location path accodring to switch is:
/Job/Items/JobItem/Fields/JobItemField[105]

In other order forms it's a different number. My question is, can you have switch look for the key word <ID>udf_Proof</ID> and identify the saved value, rather than just looking for the specific JobItemField[XX] ? I've attached a couple of screen shots showing the location path from switch as well as the XML files

Re: Grab the correct field in XML file

Posted: Tue Nov 12, 2024 7:14 pm
by jan_suhr
In the XPath you write /JobItemField[ID='udf_Proof']/Value

Then it can be in any order since we now refer to the ID=udf_Proof

Re: Grab the correct field in XML file

Posted: Tue Nov 12, 2024 10:03 pm
by magnussandstrom
jan_suhr wrote: Tue Nov 12, 2024 7:14 pm In the XPath you write /JobItemField[ID='udf_Proof']/Value

Then it can be in any order since we now refer to the ID=udf_Proof
I guess that you will need an extra forward slash in the beginning of the XPath: //JobItemField[ID='udf_Proof']/Value

Re: Grab the correct field in XML file

Posted: Tue Nov 12, 2024 10:47 pm
by jan_suhr
magnussandstrom wrote: Tue Nov 12, 2024 10:03 pm
jan_suhr wrote: Tue Nov 12, 2024 7:14 pm In the XPath you write /JobItemField[ID='udf_Proof']/Value

Then it can be in any order since we now refer to the ID=udf_Proof
I guess that you will need an extra forward slash in the beginning of the XPath: //JobItemField[ID='udf_Proof']/Value
I just ment the last part of the Xpath, but yes a double slash excludes the common part before that.