Skip to main content

Sorry, I'm new to FME and don't know which transformer to use. I am working on an FME project that is currently getting an XML response using an HTTPCaller.

The Output of the HTTPCaller has many "attributes" and then the Output is passed to an XML Fragmenter. The XML Fragmenter output is the same but has one new attribute pulled from the XML response. It then is passed to an XMLQueryExtractor which then adds another attribute.

I need to get the value of a tag and I'm wondering if I should add an XML Flattener or Fragmenter or perform this in the XML Query Extractor or some other transformer.

an example of what I need is the value in <sub3> in the following XML example and save it to a variable for later use.

<Root><sub1><sub2><sub3>value</sub3></sub2></sub1></root>

 

Thank you

You can do both really. The XMLXQueryExtractor is a little bit more elegant if you just need to extract one tag, but can be a bit trickier to set up.


You can do both really. The XMLXQueryExtractor is a little bit more elegant if you just need to extract one tag, but can be a bit trickier to set up.

Thank you for the response. Should I re-use one of the XML Transformers there or is it better to add a new one?

I'm worried about using the XML Fragmenter because I don't see a specific way to get the value of the exact tag I need and there are many tags with the same name all over but only 1 in that particular hierarchy.

 

Can I add to the current XMLXQuery Transformer?

 

The path to the exact element I want is <SearchCourseSectionProfileResult><courseSectionProfiles><courseSectionProfile><code>

 Or I guess using XPath syntax = /SearchCourseSectionProfileResult/courseSectionProfiles/courseSectionProfile/code

How do I change that into FME Xquery?

can I just add :

let $code := /SearchCourseSectionProfileResult/courseSectionProfiles/courseSectionProfile/code

return data($code)

 

Will that work?

 

Currently the XMLQueryExtractor is doing this >

let $TuitionProfileObjId := 

for $n in //*:SearchCourseSectionProfileResult/*:courseSectionProfiles/*:courseSectionProfile/*:courseSectionFees/*:courseSectionFee/*:associatedSectionFeeTuitionProfiles/*:associatedSectionFeeTuitionProfile/*:associatedTuitionProfile

 where   $n/*:description/text() = {fme:get-attribute("ROLE")} 

return data($n/*:objectId)

return ($TuitionProfileObjId)

Thank you for the help. Much appreciated


Thank you for the response. Should I re-use one of the XML Transformers there or is it better to add a new one?

I'm worried about using the XML Fragmenter because I don't see a specific way to get the value of the exact tag I need and there are many tags with the same name all over but only 1 in that particular hierarchy.

 

Can I add to the current XMLXQuery Transformer?

 

The path to the exact element I want is <SearchCourseSectionProfileResult><courseSectionProfiles><courseSectionProfile><code>

 Or I guess using XPath syntax = /SearchCourseSectionProfileResult/courseSectionProfiles/courseSectionProfile/code

How do I change that into FME Xquery?

can I just add :

let $code := /SearchCourseSectionProfileResult/courseSectionProfiles/courseSectionProfile/code

return data($code)

 

Will that work?

 

Currently the XMLQueryExtractor is doing this >

let $TuitionProfileObjId := 

for $n in //*:SearchCourseSectionProfileResult/*:courseSectionProfiles/*:courseSectionProfile/*:courseSectionFees/*:courseSectionFee/*:associatedSectionFeeTuitionProfiles/*:associatedSectionFeeTuitionProfile/*:associatedTuitionProfile

 where   $n/*:description/text() = {fme:get-attribute("ROLE")} 

return data($n/*:objectId)

return ($TuitionProfileObjId)

Thank you for the help. Much appreciated

You can use the Elements to match parameter in the XMLFragmenter to read specific elements.

 

Other than that, my best advice is to give it a try. For me, working with XML (and JSON to a lesser degree) often comes down to a process of trial and error. And that's fine, you build up valuable experience that way. Besides, as long as you're not writing to a live/production dataset until you know you're really done with the workspace there's not a whole lot that can go wrong.


Reply