Skip to main content
Solved

XML accessing attributes at parent level


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
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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
Influencer
  • 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
takashi wrote:
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
Influencer
  • November 25, 2015
aburns wrote:

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
takashi wrote:

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
Influencer
  • November 25, 2015
aburns wrote:

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?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings