Total members 11806 |It is currently Thu Nov 21, 2019 4:00 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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>





Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time

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();
}
}
 


_________________
Please recommend my post if you found it helpful


Author:
Proficient
User avatar Posts: 228
Have thanks: 0 time
Post new topic Reply to topic  [ 2 posts ] 

  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     -  
 How can i Get Brightness and Contrast values of img     -  
 Use Alpha values to draw     -  
 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     -  



Topic Tags

Java XML






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com