Select only some parts of XML code

Hey all,

I’m reading a text file which has XML contents
I mean it is XML file saved with .txt extension for readability.
I have to read only some parts of the whole file.
Does any one know how to clean the XML file for the desired contents?

Thanks in Advance!

Hello,

The file has a structure? Or is random?

If you have the file with a static structure, you can try to find the trigger and after proceed to extract the rows

It’s structured.
And I didn’t follow you after that

Hi,

Can you share an example file?

1 Like

@ray_sha
as it is XML Retrieval via the provided XML Apis can help to do it with minimal effort. Sharing of representing sample data will help us for further solution suggestions.

1 Like

sorry for the delay.

image

This is an dummy example, Now in this I don’t want to use the ex tag .
I don’t want to use the header as well i.e.

<?xml version="1.0" encoding="54545"?>

Any solution??
Thanks in advance!

1 Like

@ray_sha
Perfect.
A good pattern here in the forum is: showing input (is done above), giving expected output sample with a clear description and then we can setup a individually solution approach very fast.

Hey @ppr,

I just want to remove the ex tag and the header as I mentioned.

Thanks

@ray_sha
when it is only about this then RegEx replace will help.

replace with an empty string: “”

Pattern for the xml:
<\?xml.*\?>

grafik

Pattern for the ex tag:

<ex.*<\/ex>

grafik

2 Likes

hay @ray_sha

Let see:

  1. Orignal data:
    image
  2. Output data:
    image

if so, let me know to share with you an main file as example.

Hey,
I just want to remove the ex tag and the header.
The output data must have everything expect the header and the ex tag

Thanks

Hey,

I’ll try this approach but dont we have any XML activity for the same?

Thanks

@ray_sha

is bit confused for me now :smiley:
(you said “I wand to remove”, for me is that you wand extract, I’m right?
Let try again, your output expected is this:
image

Hey, I apologize for the confusion.
This is the desired Output

image

Thanks

Hey,

Some more clarity on this?

Thanks in Advance

@ray_sha

Please, find the output 100% accordingly with your request:

ReadXMLfile.zip (20.8 KB)

if this was a solution, please mark as.

@ray_sha
with the UiPAth.WebAPI.Activities Package we do get some activities to read in XML text into a so called XDoc. With the methods from System.Linq.XML namespace we can use several methods for XML Processing:

In your case you want to remove the header/Prolog and 1 tag. Still same recommendation: Can be done the regex replace.

Thank you
@VB_THA, @ppr

@ray_sha welcome,

Happy automations :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.