Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

EXTRACTING VALUES FROM XML FILE

Thu Oct 23, 2008 4:16 pm

I want get the value of passwaord field from the following xml file.
i tried using the java code to extract it but got only values upto o=Default
Organization"
let me know how to extract the full values.
Please let send me the code to the get the values.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<request create-oids="true" type="update"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="PortalConfig_1.2.xsd">
<portal action="locate">
<user action="update" firstname="WK0" lastname="PortalAdmin"
name="uid=wk0portaladmin,o=Default Organization" password="password">
</user>
</portal action>




Re: EXTRACTING VALUES FROM XML FILE

Thu Oct 23, 2008 4:19 pm

Hope that below implementation will help you.
Code:
private void getXmlElemStr(org.w3c.dom.Node xmlElem) {

NamedNodeMap elemAttr = null;
NodeList elemKids = null;
System.out.println("node with name is " + xmlElem.getNodeName());
if (xmlElem.getNodeType() == Node.ELEMENT_NODE) {
elemAttr = xmlElem.getAttributes();
if (elemAttr != null) {
System.out.println("elem attr size = " + elemAttr.getLength());
Node attrEl = null;
for (int i = 0; i < elemAttr.getLength(); i++) {
attrEl = elemAttr.item(i);
System.out.println("attrEl name=" + attrEl.getNodeName() + "
value = "
 + attrEl.getNodeValue());
}
}
elemKids = xmlElem.getChildNodes();
Node elNode = null;
for (int i = 0; i < elemKids.getLength(); i++) {
elNode = elemKids.item(i);
if (elNode.getNodeType() == Node.ELEMENT_NODE) {
System.out.println("node " + i + " of type:" +
elNode.getNodeType() + " with name is " + elNode.getNodeName());
this.constructXmlElemStr(elNode);
}
}

String elemValue = xmlElem.getNodeValue();
}
}
 


Post a reply
  Related Posts  to : EXTRACTING VALUES FROM XML FILE
 Read double values type from file in java     -  
 Extracting Parameters from GET or POST Request     -  
 Encrypt/Decrypt a file from source file to target file.     -  
 modulus of two values     -  
 Get image pixels Values in ITK     -  
 Dividing two Integer values     -  
 Calculate the sum of values in an array     -  
 Using Multiple Values for a Cookie in php     -  
 URL Characters and URL Encoding Values     -  
 How can i Get Brightness and Contrast values of img     -  

Topic Tags

Java XML