Grab the correct field in XML file

Post Reply
jdr_cbp_1953
Newbie
Posts: 2
Joined: Mon Nov 11, 2024 5:32 pm

Grab the correct field in XML file

Post 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
Attachments
XML Files.zip
(14.95 KiB) Downloaded 751 times
Screenshot 7944289 (Flyer Order Form).jpg
Screenshot 7944289 (Flyer Order Form).jpg (133.89 KiB) Viewed 6032 times
Screenshot 7943029 (Poster Order Form).jpg
Screenshot 7943029 (Poster Order Form).jpg (134.38 KiB) Viewed 6032 times
jan_suhr
Advanced member
Posts: 687
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Grab the correct field in XML file

Post 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
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
magnussandstrom
Advanced member
Posts: 510
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Grab the correct field in XML file

Post 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
jan_suhr
Advanced member
Posts: 687
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Grab the correct field in XML file

Post 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.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
Post Reply