OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   extract the value attribute of a node in a xml file.

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev@lists.xml.org
  • Subject: extract the value attribute of a node in a xml file.
  • From: Nishi Prafull <nishiprafull@gmail.com>
  • Date: Wed, 20 Apr 2005 12:47:05 -0700
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Xt+AVAE1xE/q81nYPbM3kymhSAqFTlK07nytXM+tNrFl1bDlFIwgQn4WKiR3xWyneH/vWtel/JgPkiMgTS9sromCC2nALjIgpw3hiOJAGQllB2tegkpo56/LY0AMSfa31JmwDUhQDWPqiZ2rutsQ+BNfmikaGVXx76s601nWavM=
  • Reply-to: Nishi Prafull <nishiprafull@gmail.com>


I have an info.xml file containing the following

<Targets AGENT_SEED="195839280">
<Target TYPE="info_apache" DISPLAY_NAME="HTTP_Server" VERSION="2.0">
<Property NAME="HTTPPort" VALUE="7779"/>

There will be other such <Target/> entries in the file but I need to
only extract the value of the Property called HTTPPort using DOM

Will the following code work -->

URL info_xml_url = new URL("file://" + "/temp/info.xml");
XMLDocument xmlDocument = null;
NodeList nodeList = null;

DOMParser parser = new DOMParser();
xmlDocument = parser.getDocument();

for(int i=0; i<nodeList.length(); i++)
if (XMLElement)nodeList.item(i). getAttribute("name").equals("HTTPPort")
   String port_val = node.getAttribute("value");

Please let me know.



News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS