rmorgan
(Rmorgan)
April 17, 2024, 10:08am
1
So I have an attached XML document. XML is my least favourite plus this looks formatted in a completely different way to any others I have seen.
If I open it in excel I would like the below 2 columns
The strange part that I cannot get my head around is when imported to excel the ns1 part of the column name is ns2 in the actual xml?
I have already:
Read the XML to text string
Deserialised It
I have a for each loop
I just trying to do a write line to get some sort of output I have tried (“ns1:…”) after the currentrow.element(“ns2:GoodsServicesDescriptionText”).value.tostring but gives me an error about the “:” after ns2
88559449_status_st96.xml (42.2 KB)
Anil_G
(Anil Gorthi)
April 17, 2024, 10:26am
2
@rmorgan
Can you please show the error message exactly
Cheers
rmorgan
(Rmorgan)
April 17, 2024, 10:28am
3
Write Line: The ‘:’ character, hexadecimal value 0x3A, cannot be included in a name.
currentItem.Element(“ns:2GoodsServicesDescriptionText”).value.tostring
ppr
(Peter Preuss)
April 17, 2024, 10:31am
4
it is about handling XML Namespaces. Find below topic elaborating on analysis and handling
XML Extraction - Handling Namespaces (Tableau, Soap, OASIS types) - Help / Community - UiPath Community Forum
we cannot use the : within the name as we have to handle properly the namespace info for the element name
rmorgan
(Rmorgan)
April 17, 2024, 10:33am
5
yeah thats way above my knowledge of XML
ppr
(Peter Preuss)
April 17, 2024, 11:00am
6
not understood what you tried to say
As described within the above linked topic, we have to handle XML Namespaces
The Namespace analysis we can short cut as we do know
we have to handle namespaces
ns2 Namespace is to handle
And can get the ns:2GoodsServicesDescriptionText elements by using the namespace e.g. like
for looping
Or can do the element value retrieval like:
rmorgan
(Rmorgan)
April 17, 2024, 11:23am
7
Think im just thick
how do we incorporate the element retrieval method in a for each loop to iterate thorugh the document and extract all the GoodsServiceDescriptions?
ppr
(Peter Preuss)
April 17, 2024, 11:31am
8
as already mentioned above and derivable to:
xnsNs2 = xDoc.Root.GetNamespaceOfPrefix("ns2")
item =
xDoc.Root.Descendants(xnsNs2 + "GoodsServicesDescriptionText")
having output:
RnD / Prototyping done with:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum
rmorgan
(Rmorgan)
April 17, 2024, 11:33am
9
gotcha, nearly there with that bit thankyou
rmorgan
(Rmorgan)
April 17, 2024, 11:35am
10
Get IN
Thank you I can work with that now!!!
ppr
(Peter Preuss)
April 17, 2024, 11:36am
11
system
(system)
Closed
April 20, 2024, 11:37am
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.