gokul1904
(Glory 01)
August 7, 2022, 6:04am
1
Hey team ,
1 .Can you please help me extract the value of “Company_Reference_ID” (CMP0061) and “Supplier_Invoice_ID” (TEST-1) from the attached xml file.
2. Also I want to update those values with new ones .
CMP0061 with CMP0062
TEST-1 with TEST-2
Please help in extracting and updating a XML
Also I have pasted a image highlighting the field I want for your reference.
MAIN_FILE - Copy.xml (3.7 KB)
Thank you , Gokul
Please take a look here, as this example will help you with Getting the value: How to find the value of xml attribute - #2 by Yoichi
These examples will help you with updating it:
[grafik]
at least lets deserialize the XML to an XDocument object
getting A Value:
[grafik]
updating B:
[grafik]
the conditional can be checked e.g. within an if activity checking A value
Hi,
Read Text File → Get xml file content as string
DeSerialize string to XDocument
& 4. You can access the value myXDoc.Root.Element(“myElement”).Value
If you want to change said value you can assign string value to it : myXDoc.Root.Element(“myElement”).Value = “new value”
5 Write Text File → overwrite the previous xml file or create a new one with value myXDoc.ToString
BR,
Topi
gokul1904
(Glory 01)
August 8, 2022, 11:28am
3
I tried the above but could not find the solution.Thank you for your input. I am still trying.
Regards,
Gokul
ppr
(Peter Preuss)
August 8, 2022, 12:07pm
4
ID - Company_Reference_ID
xnsWD
[urn:com.workdayi/bsvcdadass]
xDoc.root.Descendants(xnsWD + "ID").Where(Function (x) x.Attribute(xnsWD + "type").value.Equals("Company_Reference_ID")).first()
[<wd:ID wd:type="Company_Reference_ID" xmlns:wd="urn:com.workdayi/bsvcdadass">CMP0061</wd:ID>]
xDoc.root.Descendants(xnsWD + "ID").Where(Function (x) x.Attribute(xnsWD + "type").value.Equals("Company_Reference_ID")).first().value = "ABC"
"ABC"
ID - Supplier_Invoice_ID can be managed similar
It is always about handling xml namespaces
Going ahead
Serializing the XML - output: xDoc | DataType: XDocument:
[grafik]
Checking if we have to handle XML namespaces
[grafik]
We do have:
[grafik]
Checking for some children:
[grafik]
Defining Namespace Variable
[grafik]
In some cases, we can also do: Assign Activity - xnsDefault = xDoc.Root.Name.Namespace
Checkin the retrieval
[grafik]
xDoc.Descendants(xnsDefault + "productVersion")
GetDescendants { [<productVersion build="456" xmlns="http://tableau.com/api">123</…
Working with the immediate panel helps us for the prototyping
Please check also your other open topics and and mark the solved ones with the solution flag. Thanks
1 Like
gokul1904
(Glory 01)
August 15, 2022, 7:11pm
5
Thanks a lot @ppr . Can you please also let me know how do I update those values -
Pasted from question ---->
2. Also I want to update those values with new ones .
CMP0061 with CMP0062
TEST-1 with TEST-2
Regards,
Gokul
ppr
(Peter Preuss)
August 15, 2022, 9:20pm
6
we show cased already above:
use an assign activity for this
1 Like
system
(system)
Closed
August 19, 2022, 6:53am
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.