mironb
(Mironb)
March 20, 2023, 5:53am
1
Does anyone know why I can’t extract the value of the customerID, from the XML?
In the past I did the same thing and I succeeded.
I have the XML in the XmlOutputDoc and I use :
XmlOutputDoc.Element(“export”).Element(“batchid”).Element(“customer”).Element(“header”).Element(“customerID”).Value
This is the value of XmlOutputDoc
Gokul001
(Gokul Balaji)
March 20, 2023, 5:57am
2
Hi @mironb
when you try to use an object that has not been initialized .
To avoid this error, you can choose to check for the null and provide a default value.
You can also explicitly check for null from method calls and throw a custom exception
Check out this thread
Regards
Gokul
ushu
(Usha kiranmai)
March 20, 2023, 5:58am
3
Hi @mironb Can you share that sample XML input file
mironb
(Mironb)
March 20, 2023, 5:59am
4
Gokul001:
when you try to use an object that has not been initialized .
To avoid this error, you can choose to check for the null and provide a default value.
You can also explicitly check for null from method calls and throw a custom exception
Check out this thread
Hi @Gokul001
But debug it and you can see that there is no value that is initialized to NULL
I have attached a screenshot
ushu
(Usha kiranmai)
March 20, 2023, 6:08am
6
Can you also share the expression that you have written in the write line activity
mironb
(Mironb)
March 20, 2023, 6:10am
7
@ushu
XmlOutputDoc.Element(“export”).Element(“batchid”).Element(“customer”).Element(“header”).Element(“customerID”).Value
ushu
(Usha kiranmai)
March 20, 2023, 6:15am
8
@mironb can you please do one quick test. Try to print batch id value
XmlOutputDoc.Element(“export”).Element(“batchid”).Value
This it to identify, is XmlOutputDoc is empty or is it something wrong with the exp
mironb
(Mironb)
March 20, 2023, 6:21am
9
@ushu
This is the XmlOutputDoc :
As I mentioned you can see the in the post every value is not null
Anil_G
(Anil Gorthi)
March 20, 2023, 6:22am
10
@mironb
If you observe the structure of xml customer tag is under export but not under the batch id tag…that is the reason its failing …you have to use like this
XmlOutputDoc.Element(“export”).Element(“customer”).Element(“header”).Element(“customerID”).Value
Cheers
system
(system)
Closed
March 23, 2023, 6:26am
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.