How to read Xml Data File in Ui Path

Hi sandeep13 sir,

Getxmloutput.element(“component”). element (“header”). element (“publicationMeta”). element (“publisherInfo”).tostring
Message Box: Object reference not set to an instance of an object.

How can i solve this sir

1 Like

could you share xml file or screenshot?

1 Like

Hi sandeep13 sir,
Find Below Attachment

cft2cftm20140013.xml (84.2 KB)

1 Like

try this

Getxmloutput.element(“component”). element (“header”). element (“publicationMeta”). element (“publisherInfo”).value

1 Like

Hi sandeep13 sir,

image

Message Box: Object reference not set to an instance of an object.

3 Likes

@Logesh_Kumar


its works but when i remove addtional value from xml file
like

1 Like

Hi sandeep13 sir,
Thank You sir,
But My Requirement

xmlns:wiley=“http://www.wiley.com/namespaces/wiley/wiley
This Component tag have this to i search if this sentence hear no problem if not hear means i put that text i replace that text

If I check The Component tag have that text if not have i put that text
xmlns:wiley=“http://www.wiley.com/namespaces/wiley/wiley

1 Like

Hi sandeep13 sir,

How to find the type value and sort values in title element

1 Like

@Logesh_Kumar
using Attribute method
XMLDoc.Element(“component”).Attribute(“Title”).ToString

1 Like

Hi sandeep13 sir,

I try many, but coming Errors,

getXmloutputTxt.Element(“titleGroup”).Element(“title”).Attribute(“sort”).ToString
getXmloutputTxt.Element(“titleGroup”).Attribute(“title”).ToString
getXmloutputTxt.Element(“component”).Attribute(“Title”).ToString

1 Like

@Logesh_Kumar

i print level attribute of publicationMeta element
XMLDoc.Element(“component”).Element(“header”).Element(“publicationMeta”).Attribute(“level”).Value

1 Like

@Logesh_Kumar

it’s working but as i said i remove additional value

XMLDoc.Element(“component”).Element(“header”).Element(“publicationMeta”).Element(“titleGroup”).Element(“title”).Attribute(“type”).Value

1 Like

Hi sandeep13 sir,
Now it’s working Fine
That Attribute Value I replace The Text How

1 Like

i didn’t get you
you want replace the string??
using replace method of String
value.replace(oldvalue,new value)

1 Like

Hi sandeep13 sir,

I want replace the string

XMLDoc.Element(“component”).Element(“header”).Element(“publicationMeta”).Element(“titleGroup”).Element(“title”).Attribute(“type”).Value

This query getting one value That value i replace to some text

1 Like

XMLDoc.Element(“component”).Element(“header”).Element(“publicationMeta”).Element(“titleGroup”).Element(“title”).Attribute(“type”).Value.ToString.Replace(“oldtext”,“newtext”)

1 Like

Hi sandeep13 sir,

If I check Particular Element inside particular attributes If it is There means Exit and not There is Insert that values in That Xml file

If It is Possible sir ?

@Logesh_Kumar
yes you can, you need to explore Add, AddAnnotation method.

Hi sandeep13 sir,

How To add in Particular Element in Add some text I am trying But Not Getting sir

Hi,

I want to check whether a XML tag/element is present in the XML file or not.
How can i achieve this.

I have read the XML file in to string using Deserilization operation and looped the to get all the similar kind of tags.

item.Element(“reporttype”)

I want to check whether this tag is present in the XML file or not.

Kindly help me.