You need to sign in to do that
Don't have an account?
How to loopthrough an XML string and get the Attribute values
hi all,
I am writing an apex webservice which reads XNL string from a thirdparty application.
the XMl looks like the Below format
<root name="test" place="dc">
<childone>
<item firstname="value" lastname="value"></item>
<item firstname="value" lastname="value"></item>
</childone>
</root>
tha code i wrote looks as follows:
XMLStreamReader reader =new XMLStreamreader(str)
reader.setClalescing(true)
try
{
while(reader.hasNext())
{
if(reader.getEventtype()=xmltag.STARTELEMENT() && reader.getLocalName()='root)
{
string str1=reader.getAttributeValue(Null,'name');
string str2=reader.getAttributeValue(Null,'Place');
}
if(reader.getEventtype()=xmltag.STARTELEMENT() && reader.getLocalName()='childone')
{
reader.nexttag();
if(reader.getEventtype()=xmltag.STARTELEMENT() && reader.getLocalName()='item')
{
here i am trying to get the attribute values of all items.how do i do that.
}
}
}
}