Support Questions

Find answers, ask questions, and share your expertise

Nifi:How to remove xml tag from xml response data?

avatar
Contributor

I want to replace <?xml version="1.0" encoding="utf-8"?> tag by <DailyData></DailyDate>

I used to replace text nifi processor with this search value:^<[^>]+>(.*)<\/\w+>$ and I put replace value like this in replace value <DailyData>$1</DailyData> but I got error like this inside xml file:

This page contains the following errors:

error on line 1 at column 4081: XML declaration allowed only at the start of the document Below is a rendering of the page up to the first error.

what should I change?

1 ACCEPTED SOLUTION

avatar
Master Guru

@sally sally, can you make use of below search property

^<[^>]+>(.*)\<\/\?.*\>$ 

Replacetext Configs:-

40419-replacetext-regex.png

Input:-

<?xml version="1.0" encoding="utf-8"?>abc</?xml version="1.0" encoding="utf-8"?>
Output:-
<DailyData>abc</DailyData>

View solution in original post

1 REPLY 1

avatar
Master Guru

@sally sally, can you make use of below search property

^<[^>]+>(.*)\<\/\?.*\>$ 

Replacetext Configs:-

40419-replacetext-regex.png

Input:-

<?xml version="1.0" encoding="utf-8"?>abc</?xml version="1.0" encoding="utf-8"?>
Output:-
<DailyData>abc</DailyData>