Skip to main content
Solved

Parse XML response (Tuple??)


goatboyboz
Contributor
Forum|alt.badge.img+5

Hi All, i have been banging my head against this for a while. Im trying to parse an api call response I get ( XML returned) . I have tried Flattening it. I have tried Fragmenting it, I have tried swearing at it. None of the things I have tried have worked. I don't really understand how this data is structured. Its nested I think, with something like tuples??? there is a Name, Number and Text for each attribute?? Any help or direction appreciated. Happy to learn. I'm trying to return the "number" value of NZTM 2000 Northing and NZTM 2000 Easting as attributes... Many Thanks for your suggestions.

Best answer by ebygomm

If you are just trying to get those two values - NZTM 2000 Northing and NZTM 2000 Easting i would probably use the XMLXQueryExtractor

for $ x in //CustomField
where $x[matches(Name,"NZTM 2000.*")]
return 
{fme:set-attribute($x/Name,$x/Number/text())}

Expose NZTM 2000 Easting, NZTM 2000 Northing under Expose Attributes

View original
Did this help you find an answer to your question?

3 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • Best Answer
  • October 13, 2021

If you are just trying to get those two values - NZTM 2000 Northing and NZTM 2000 Easting i would probably use the XMLXQueryExtractor

for $ x in //CustomField
where $x[matches(Name,"NZTM 2000.*")]
return 
{fme:set-attribute($x/Name,$x/Number/text())}

Expose NZTM 2000 Easting, NZTM 2000 Northing under Expose Attributes


nielsgerrits
VIP

This can de done by the XmlFragmenter.

Fragment path: Response/CustomFields/CustomField

Enable Flattening = Yes

Expose attributes: UUID, Name Number.

Then filter only the features with the oordinates, rename the Number attributes, and merge them together with an aggregator.


goatboyboz
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • October 13, 2021
ebygomm wrote:

If you are just trying to get those two values - NZTM 2000 Northing and NZTM 2000 Easting i would probably use the XMLXQueryExtractor

for $ x in //CustomField
where $x[matches(Name,"NZTM 2000.*")]
return 
{fme:set-attribute($x/Name,$x/Number/text())}

Expose NZTM 2000 Easting, NZTM 2000 Northing under Expose Attributes

Many Thanks @ebygomm​    just what i needed and i learnt about the xmlxQueryExtractor and syntax at the same time, great!!.I do like learning new stuff!!

 I appreciate your help

and thanks for your idea too @nielsgerrits​ .

Steve


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