Help parsing XML

Hi All,

I am trying to parse two xmls.

<?xml version="1.0" encoding="UTF-8"?>

< Students xmlns:http://xyz.com/ns1>
< Student >
< Name >Alice< /Name >
< IsClassCaptian >true< /IsClassCaptian >
< /Student >
< Student >
< Name >Bob< /Name >
< IsClassCaptian >false< /IsClassCaptian >
< /Student >
< /Students >

<?xml version="1.0" encoding="UTF-8"?> < Students xmlns:http://xyz.com/ns2> < Student > < Name>Alice < IsClassCaptian/ > < /Student > < Student > < Name >Bob< /Name > < /Student > < /Students >

Both xml has different name spaces.
In the first xml, < IsClassCaptain > element has value either true or false.
But in the second xml, presence of element alone tells it is true.

I am having trouble parsing these two xml with a common code.I tried something like this

type Student struct { Name string 'xml:"Name"' XMLName xml.Name 'xml:IsClassCaptain' }

This works fine for the second case, but for the first case I also need the value to find if it is true or false.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.