parse XML file
May 03, 2018
12:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
May 03, 2018
12:35 AM
parse XML file
Hi,
is there any way to access tags with variable?
My Sample file is "xmlDocument":
<reading xmlns="http://cyantechnology.com/dean/v1"> <link href="https://cyan-hes-vip-master:8000/v1/readings/824cde15-f6b6-4819-abbe-8524d16f2972" method="delete" rel="delete"/> <link href="https://cyan-hes-vip-master:8000/v1/readings/824cde15-f6b6-4819-abbe-8524d16f2972" method="get" rel="reading"/> <link href="https://cyan-hes-vip-master:8000/v1/dcus/969c515f-cf50-4861-8029-3070e891937b" method="get" rel="dcu"/> <link href="https://cyan-hes-vip-master:8000/v1/meters/91b69412-f06d-45e4-83a3-6fce6694c3bb" method="get" rel="meter"/> <meter-serial-number>17254120</meter-serial-number> <meter-timestamp unit="iso8601">2018-01-23T20:26:15Z</meter-timestamp> <dcu-timestamp unit="iso8601">2018-01-23T20:26:15Z</dcu-timestamp> <rtc unit="iso8601">2018-01-24T01:53:54-00:00</rtc> <configuration_manufacturer>Larsen & Toubro Limited</configuration_manufacturer> <configuration_serial>S17254120</configuration_serial> <configuration_firmware_version>7PB0L.60</configuration_firmware_version> <reading/>
if i want to read "configuration_manufacturer" data. i ll use below one.
result = xmlDocument.*::configuration_manufacturer
Like this how can i read "meter-timestamp" data?
Is anyway to access with variable?
var tag = "meter-timestamp"; result = xmlDocument.*::tag
Regards,
Sathishkumar C.
Solved! Go to Solution.
ACCEPTED SOLUTION
Accepted Solutions
May 03, 2018
12:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
May 03, 2018
12:45 AM
Hi Sathish,
You can directly use xmlDocument.*::meter-timestamp
If it throws error, remove "-" from XML string. You can use below command
XMLString.replace("-","") and try to use
xmlDocument.*::metertimestamp
Regards
Velkumar R
You can directly use xmlDocument.*::meter-timestamp
If it throws error, remove "-" from XML string. You can use below command
XMLString.replace("-","") and try to use
xmlDocument.*::metertimestamp
Regards
Velkumar R
2 REPLIES 2
May 03, 2018
12:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
May 03, 2018
12:45 AM
Hi Sathish,
You can directly use xmlDocument.*::meter-timestamp
If it throws error, remove "-" from XML string. You can use below command
XMLString.replace("-","") and try to use
xmlDocument.*::metertimestamp
Regards
Velkumar R
You can directly use xmlDocument.*::meter-timestamp
If it throws error, remove "-" from XML string. You can use below command
XMLString.replace("-","") and try to use
xmlDocument.*::metertimestamp
Regards
Velkumar R
May 03, 2018
01:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
May 03, 2018
01:24 AM
It is fine.
i replaced "dcu-timestamp".
