Skip to main content
Question

Explode xml when read from a string

  • August 19, 2014
  • 4 replies
  • 42 views

I am tying to read xml metadata from a geodatabase but it is contained in one string as opposed to when you read in an xml file it would expose all of the elements.  I've tried a few different xml transformers and online help docs but cannot find a solution.  

 

Just to recap I am able to read in an xml file and process it the way i want but I now want to read in the xml from exposing the metadata in a geodatabase using geodb_metadata_string.  The problem is that the entire xml file is contained within one string now and I don't know how to explode the tags i want.  

 

Cheers
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.

4 replies

david_r
Celebrity
  • August 20, 2014
Hi,

 

 

you can use the XMLFragmenter to split up an attribute containing an XML document into separate features, just like the XML reader.

 

 

David

  • Author
  • August 20, 2014
Thank you.  Seperating the 'Elements to Match' with a whitespace did the trick. 

 

 


  • Author
  • August 20, 2014
One more thing... How would you flatten a list?  I have this as my xml:

 

...

 

<idAbs>The Transportation District dataset is comprised of all the polygons that represent... </idAbs>

 

<searchKeys>

 

     <keyword>transportation</keyword>

 

     <keyword>district</keyword>

 

     <keyword>jurisdiction</keyword>

 

     <keyword>road</keyword>

 

</searchKeys>

 

...

 

Within xmlFlattener I can flatten idAbs just fine but don't know what to put to get each keyword as a list.  I tried searchKeys and expose searckKeys.keyword{} but it didn't work.  After the flattener I pass it into the JSONTemplater with this template:

 

{

 

    "summary" : fme:get-attribute("idAbs"),

 

    "description" : fme:get-attribute("idPurp"),

 

    "credits" : fme:get-attribute("idCredit"),

 

    "tags" : [ fme:get-list-attribute("searchKeys.keyword{}") ]

 

}

 

The template is written this way becasue i got it working with an xml file that i read in (as opposed to now where I am reading the xml from a string).  I think there must be some easy way but the documentation is not easy.  

  • Author
  • August 20, 2014
I just got it!  What i did was enter searchKeys as the Element to Match in Flatten Paths and then entered keyword{} in the Expose Attribute (on the xmlFlattener).  Then on th eJSONTemplater I used "tags" : [ fme:get-list-attribute("keyword{}") ].  

 

In case anyone else has this problem.