Skip to main content
Solved

XML accessing attributes at parent level

  • November 25, 2015
  • 6 replies
  • 31 views

Forum|alt.badge.img
Hi All XML Format as follows: <?xml version="1.0" encoding="UTF-8"?> <Flows><SCN> <SystemCodeNumber>N11111J</SystemCodeNumber> <FlowType>Scoot</FlowType> <ShortDescription/> <Northing>0.00</Northing> <Easting>0.00</Easting> <Flows> <Flow Date="2015-05-03 05:08:35">1.0</Flow> <Flow Date="2015-05-03 05:13:35">4.0</Flow> etc. I am accessing an XML file as a single merged feature type as i would like an output as follows: SystemCodeNumber,Northing,Easting,Speed,Flow,Date N11111J,0.00,0.00,,1.0,2015-05-03 05:08:35 N11111J,0.00,0.00,,4.0,2015-05-03 05:13:35 N11111J,0.00,0.00,,1.0,2015-05-03 05:18:35 N11111J,0.00,0.00,,0.0,2015-05-03 05:23:35 as so on. I am getting the elements i want:

and flattening the elements: not the output is fine, im getting what i require out: I have my SystemCodeNumber, Easting and Northing out. I would like to add them as i one to many so i can get my output as required. At the moment im testing to see if the attribute exists and storing it in a VariableSetter and Retrieving it before writing. What im trying to figure out (without having to go down the python route as i can do it in python is if we have a simpler way to do this? Thanks

Best answer by takashi

Hi, try setting "SCN" to the Elements to Match parameter. Values of the attribute "Flows/Flow/@Date" will be stored in a list attribute called "Flows.Flow{}.Date". You can then explode features on "Flows.Flow{}" with the ListExploder. However, I'm not sure how the "Speed" should be treated, since "Speed" elements are not shown in your sample XML doc. Takashi
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

takashi
Celebrity
  • Best Answer
  • November 25, 2015
Hi, try setting "SCN" to the Elements to Match parameter. Values of the attribute "Flows/Flow/@Date" will be stored in a list attribute called "Flows.Flow{}.Date". You can then explode features on "Flows.Flow{}" with the ListExploder. However, I'm not sure how the "Speed" should be treated, since "Speed" elements are not shown in your sample XML doc. Takashi

Forum|alt.badge.img
  • Author
  • November 25, 2015
Hi, try setting "SCN" to the Elements to Match parameter. Values of the attribute "Flows/Flow/@Date" will be stored in a list attribute called "Flows.Flow{}.Date". You can then explode features on "Flows.Flow{}" with the ListExploder. However, I'm not sure how the "Speed" should be treated, since "Speed" elements are not shown in your sample XML doc. Takashi

Hi Takashi. Apologies, the Speed element gets added in a FeatureMerger later in the workbench.

I will give your advice a go and let you know, thanks for your reply.


takashi
Celebrity
  • November 25, 2015

Hi Takashi. Apologies, the Speed element gets added in a FeatureMerger later in the workbench.

I will give your advice a go and let you know, thanks for your reply.

OK. In addition, to improve performance, it's better to remove unnecessary attributes before exploding.


Forum|alt.badge.img
  • Author
  • November 25, 2015
Hi I have done the following:

And this is the output. I have lost the list but thats not an issue. I would like the fields that have attributes from SystemCodeNumber, Easting, Northing to replicate to all the rows ie 1toM?


Forum|alt.badge.img
  • Author
  • November 25, 2015

OK. In addition, to improve performance, it's better to remove unnecessary attributes before exploding.

looks okay but the issue is with replicating the SCN,X,Y, into all rows?


takashi
Celebrity
  • November 25, 2015

looks okay but the issue is with replicating the SCN,X,Y, into all rows?

This is my settings and the result from your sample XML. Isn't the resulting table your desired one?