You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by "Jens M. Kofoed" <jm...@gmail.com> on 2021/07/29 04:52:44 UTC
XML Reader: Tags with Attributes not working
Hi
I'm trying to convert some xml data, and struggle with xml attributes and
field content. Therefore I tried the example in the documentation for the
XML Reader but this doesn't work either.
By using the data and settings from the example I only get the content
value not the data from the tag.
(Another think is, that in the examples are missing a }. so you can't just
copy/past from the documentation page:
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.7.0/org.apache.nifi.xml.XMLReader/additionalDetails.html
)
GenerateFlowfile -> ConvertRecord (XMLReader->JSONSetWriter)
A GenerateFlowfile process with this text:
<record>
<field_with_attribute attr="attr_content">content of
field</field_with_attribute>
</record>
XMLReader Settings:
Schema Access Strategy: Use 'Schema Text' Property
Schema Text:
{ "name": "test",
"namespace": "nifi",
"type": "record",
"fields": [
{ "name": "field_with_attribute",
"type":
{ "name": "RecordForTag",
"type": "record",
"fields" : [
{ "name": "attr", "type": "string"},
{"name": "field_name_for_content", "type": "string"}
]
}
}
]
}
Expect Records as Array: false
Attribute Prefix: prefix_
Field Name for Content: field_name_for_content
The JSON Output is the following:
{
"field_with_attribute" : {
"attr" : null,
"field_name_for_content" : "content of field"
}
}
Kind regards
Jens M. Kofoed