Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi
XML
All,
I want to read value from following < Line> xml using java.. In < Line>,data is in format of key and value pair.. i want to read only values..could u plz help me in this

<?xml version="1.0" encoding="UTF-8" ?> 
<sales>
<item>
<line>002:OR,004:0001,002:01,002:01,007:SCEM_02,000:,007:590,000,002:KG,002:PC;/</line> 
</item>
</sales>

Regards,
Glory
Posted
Updated 23-Jun-12 8:06am
v3

look this simple example :-

C#
function ReadXml(retval,AD8)
{
var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
        xmldoc.loadXML(retval);

        var node=xmldoc.getElementsByTagName('UrFieldName');
        //alert(node[0].childNodes[0].data);
        if (node[0]!=null) AD8.value=node[0].childNodes[0].data;

    }

retval is your xml file data value.
 
Share this answer
 
Comments
Sandeep Mewara 23-Jun-12 2:51am    
OP said Java... not Javascript!
Have a look at the following on how to read XML using Java:
XML and Java - Parsing XML using Java Tutorial[^]
How to read XML file in Java – (DOM Parser)[^]
How do I read an XML document using JDOM?[^]

Just Google for more in case needed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900