Need help on parsing xml file...
Hi all,
I need to collect some data from an Xml file using java. I have the following code with me but I am unable to get the required result. I am unable to get the data from the tags belonging to the header and footer elements. Please find the code and the sample xml file below.
Program to parse XML:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class JobLogDetails3{
//No generics
List myJobs;
Document dom;
public JobLogDetails3(){
//create a list to hold the job objects
myJobs = new ArrayList();
public void runJobDetails() {
//parse the xml file and get the dom object
parseXmlFile();
//get each joblog element and create a job object
parseDocument();
//Iterate through the list and print the data
printData();
private void parseXmlFile(){
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation of the XML file
dom = db.parse("test.xml");
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch(SAXException se) {
se.printStackTrace();
}catch(IOException ioe) {
ioe.printStackTrace();
private void parseDocument(){
//get the root elememt
Element docEle = dom.getDocumentElement();
//get a nodelist of <joblog> elements
NodeList nl = dom.getElementsByTagName("*");
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the joblog element
Element el = (Element)nl.item(i);
//get the joblog object
Job J = getJob(el);
//add it to list
myJobs.add(J);
* I take an joblog element and read the values in, create
* an joblog object and return it
* @param JobEl
* @return
private Job getJob(Element JobEl) {
//for each <joblog> element get text or int values of
//name ,id, age and name
String jobServer = getTextValue(JobEl,"server");
String jobName = getTextValue(JobEl,"name");
String jobClient = getTextValue(JobEl,"machine_name");
String jobStart = getTextValue(JobEl,"start_time");
String jobType = getTextValue(JobEl,"type");
String jobEnd = getTextValue(JobEl,"end_time");
String jobSize = getTextValue(JobEl,"new_processed_bytes");
//Create a new Job with the value read from the xml nodes
Job J = new Job(jobServer,jobName,jobClient,jobStart,jobType,jobEnd,jobSize);
return J;
* I take a xml element and the tag name, look for the tag and get
* the text content
* i.e for <employee><name>John</name></employee> xml snippet if
* the Element points to employee node and tagName is name I will return John
* @param ele
* @param tagName
* @return
private String getTextValue(Element ele, String tagName) {
String textVal = null;
NodeList nl = ele.getElementsByTagName(tagName);
if(nl != null && nl.getLength() > 0) {
Element el = (Element)nl.item(0);
textVal = el.getFirstChild().getNodeValue();
return textVal;
* Calls getTextValue and returns a int value
* @param ele
* @param tagName
* @return
private int getIntValue(Element ele, String tagName) {
//in production application you would catch the exception
return Integer.parseInt(getTextValue(ele,tagName));
* Iterate through the list and print the
* content to console
private void printData(){
System.out.println("No of Jobs '" + myJobs.size() + "'.");
Iterator it = myJobs.iterator();
while(it.hasNext()) {
System.out.println(it.next().toString());
public static void main(String[] args){
//create an instance
JobLogDetails JLD = new JobLogDetails();
//call run example
JLD.runJobDetails();
Job Class
public class Job {
private String jobServer;
private String jobName;
private String jobClient;
private String jobStart;
private String jobType;
private String jobEnd;
private String jobSize;
public Job(){
public Job(String jobServer,String jobName,String jobClient,String jobStart,String jobType,String jobEnd,String jobSize ) {
this.jobServer = jobServer;
this.jobName = jobName;
this.jobClient = jobClient;
this.jobStart = jobStart;
this.jobType = jobType;
this.jobEnd = jobEnd;
this.jobSize = jobSize;
public String getjobServer() {
return jobServer;
public void setjobServer(String jobServer) {
this.jobServer = jobServer;
public String getjobName() {
return jobName;
public void setjobname(String jobName) {
this.jobName = jobName;
public String getjobClient() {
return jobClient;
public void setjobClient(String jobClient) {
this.jobClient = jobClient;
public String getjobStart() {
return jobStart;
public void setjobStart(String jobStart) {
this.jobStart = jobStart;
public String getjobType() {
return jobType;
public void setjobType(String jobType) {
this.jobType = jobType;
public String getjobEnd() {
return jobEnd;
public void setjobEnd(String jobEnd) {
this.jobEnd = jobEnd;
public String getjobSize() {
return jobSize;
public void setjobSize(String jobSize) {
this.jobSize = jobSize;
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(getjobServer());
sb.append(",");
sb.append(getjobName());
sb.append(",");
sb.append(getjobClient());
sb.append(",");
sb.append(getjobType());
sb.append(",");
sb.append(getjobStart());
sb.append(",");
sb.append(getjobEnd());
sb.append(",");
sb.append(getjobSize());
sb.append(",");
return sb.toString();
Sample XML File:
<?xml version="1.0" encoding="UTF-16" ?>
- <joblog>
<job_log_version version="2.0" />
- <header>
<filler>======================================================================</filler>
<server>Job server: TGBBAK</server>
<name>Job name: TGBSAP4-SQL-SQL DB Servers S2T - High-Weekly Full Backup</name>
<start_time>Job started: 26 September 2011 at 01:00:04</start_time>
<type>Job type: Backup</type>
<log_name>Job Log: GFD_TGBBAK_71887.xml</log_name>
<filler>======================================================================</filler>
</header>
<media_mount_date>Drive and media mount requested: 26/09/2011 01:00:04</media_mount_date>
- <media_drive_and_media_info>
<media_mount_date>Drive and media information from media mount: 26/09/2011 01:00:39</media_mount_date>
<robotic_library_name>Robotic Library Name: HP 1</robotic_library_name>
<drive_name>Drive Name: LTO4_2</drive_name>
<slot>Slot: 43</slot>
<media_label>Media Label: 000059L</media_label>
<media_guid>Media GUID: {a6ca0062-7a6f-4b4b-8144-732ca25f2f9d}</media_guid>
<media_overwrite_date>Overwrite Protected Until: 25/10/2011 19:24:58</media_overwrite_date>
<media_append_date>Appendable Until: 02/10/2011 14:00:30</media_append_date>
<media_set_target>Targeted Media Set Name: Weekly Tape</media_set_target>
</media_drive_and_media_info>
- <backup>
<filler>======================================================================</filler>
<title>Job Operation - Backup</title>
<append_or_overwrite>Media operation - append.</append_or_overwrite>
<compression>Compression Type: Hardware [if available, otherwise none]</compression>
<verify_option>WARNING: The option 'Verify after backup completes' was not selected. Performing a verify operation to make sure that media can be read after the backup has completed is recommended.</verify_option>
<filler>======================================================================</filler>
- <machine>
<machine_name>TGBSAP4.Tetley.Grp</machine_name>
<info>Network control connection is established between 10.22.2.18:3271 <--> 10.22.2.4:10000</info>
<info>Network data connection is established between 10.22.2.18:3301 <--> 10.22.2.4:3094</info>
- <set>
<set_resource_name>TGBSAP4.Tetley.Grp</set_resource_name>
<tape_name>Family Name: "Media created 25/09/2011 13:59:55"</tape_name>
- <volume>
<display_volume>Backup of "TGBSAP4.Tetley.Grp "</display_volume>
</volume>
<description>Backup set #45 on storage media #1 Backup set description: "Weekly Full Backup"</description>
<backup_type>Backup Method: Full - Back up entire database or filegroup</backup_type>
<agent_started>Microsoft SQL Server Agent: Started</agent_started>
<start_time>Backup started on 26/09/2011 at 01:01:45.</start_time>
- <database>
<database>Database PRD</database>
</database>
- <database>
<database>Database master</database>
</database>
- <database>
<database>Database model</database>
</database>
- <database>
<database>Database msdb</database>
</database>
<end_time>Backup completed on 26/09/2011 at 02:42:25.</end_time>
- <summary>
<backed_up_database>Backed up 4 databases</backed_up_database>
<new_processed_bytes>Processed 573363576542 bytes in 1 hour, 40 minutes, and 40 seconds.</new_processed_bytes>
<vlm_hist_rateformat2>Throughput rate: 5432 MB/min</vlm_hist_rateformat2>
</summary>
<filler>----------------------------------------------------------------------</filler>
</set>
</machine>
</backup>
- <footer>
<filler>======================================================================</filler>
<end_time>Job ended: 26 September 2011 at 02:43:12</end_time>
<engine_completion_status>Job completion status: Successful</engine_completion_status>
<filler>======================================================================</filler>
<completeStatus>19</completeStatus>
</footer>
</joblog>
1. your code does not compile (in your main method you try to create an instance of a class which does not exist).
2. your XML document is not well formed.
+[Fatal Error] test.xml:34:74: The content of elements must consist of well-formed character data or markup.+
org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
Maybe there are other problems but you can start by fixing these.
Similar Messages
-
Urgent : Need help in parsing XML from Sharepoint and save it into DB
Hi ,
I am Sharepoint guy and a newbie in Oracle . PL/SQL
I am using UTL_DBWS Package to call a Sharepoint WebService " and was sucessfull , Now the xml has to be parsed and stored into a Table. I am facing the issue as the XML has a different namesoace and normal XPATH query is not working
Below is the XML and need help in parsing it
declare
responsexml sys.XMLTYPE;
testparsexml sys.XMLTYPE;
begin
responsexml := sys.XMLTYPE('<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetListItemsResult>
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<rs:data ItemCount="2">
<z:row ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Test Title 1" ows_ID="1" ows_owshiddenversion="1" ows_UniqueId="1;#{9C45D54E-150E-4509-B59A-DB5A1B97E034}" ows_FSObjType="1;#0" ows_Created="2009-09-12 17:13:16" ows_FileRef="1;#Lists/Tasks/1_.000"/>
<z:row ows_MetaInfo="2;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Testing Tasks" ows_ID="2" ows_owshiddenversion="1" ows_UniqueId="2;#{8942E211-460B-422A-B1AD-1347F062114A}" ows_FSObjType="2;#0" ows_Created="2010-02-14 16:44:40" ows_FileRef="2;#Lists/Tasks/2_.000"/>
</rs:data>
</listitems>
</GetListItemsResult>
</GetListItemsResponse>');
testparsexml := responsexml.extract('/GetListItemsResponse/GetListItemsResult/listitems/rs:data/z:row/@ows_Title');
DBMS_OUTPUT.PUT_LINE(testparsexml.extract('/').getstringval());
end;
The issue is with rs:data , z:row nodes.... please suggest how to handle these kind of namespaces in Oracle
I need the parse the attribute "ows_Title" and save it into a DB
this script would generate "Error occured in XML Parsing"
Help is appriciated, thanks for lookingSQL> SELECT *
FROM XMLTABLE (
xmlnamespaces ('http://schemas.microsoft.com/sharepoint/soap/' as "soap",
'#RowsetSchema' AS "z"
'for $i in //soap:*//z:row return $i'
PASSING xmltype (
'<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetListItemsResult>
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<rs:data ItemCount="2">
<z:row ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Test Title 1" ows_ID="1" ows_owshiddenversion="1" ows_UniqueId="1;#{9C45D54E-150E-4509-B59A-DB5A1B97E034}" ows_FSObjType="1;#0" ows_Created="2009-09-12 17:13:16" ows_FileRef="1;#Lists/Tasks/1_.000"/>
<z:row ows_MetaInfo="2;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Testing Tasks" ows_ID="2" ows_owshiddenversion="1" ows_UniqueId="2;#{8942E211-460B-422A-B1AD-1347F062114A}" ows_FSObjType="2;#0" ows_Created="2010-02-14 16:44:40" ows_FileRef="2;#Lists/Tasks/2_.000"/>
</rs:data>
</listitems>
</GetListItemsResult>
</GetListItemsResponse>')
columns ows_MetaInfo varchar2(20) path '@ows_MetaInfo',
ows_Title varchar2(20) path '@ows_Title',
ows__ModerationStatus varchar2(20) path '@ows__ModerationStatus'
OWS_METAINFO OWS_TITLE OWS__MODERATIONSTATUS
1;# Test Title 1 0
2;# Testing Tasks 0
2 rows selected. -
Need help with checking xml files
Hello!
I would like to ask you for advice.
I have following task to do: I need to compare values in XML file with one of databases. Have you any ideas hot to do it? How to parse it using PL/SQL level?
thanks for replyOracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
I have following problem. External firm sending me a XML file with some fields for example: <price>5000$</price>;
In my DB i have table with this column and i have to make a script in PL/SQL which is finding in my DB fields and compare with fields written in this XML file.
Thanks. -
Need help in writing XML file!!!
dear friends:
I'm a learner in J2ME, and I understood how to parse a simple XML document with SAX parser, but it don't supply methods to write a XML file or store my data to a XML file.
Somebody can tell me how to do?
Thanks in advance.hello
you can also read this:
http://www.cafeconleche.org/books/xmljava/
nice stuff !
peace -
Need help with loading XML file
Hello,
I have been browsing the web/forums for an example on how to do this for a few days now. I managed to get this working in Flash Pro quite easily but I think I am missing something when I want to do the same thing in Flex.
Basically I want to load an XML file and then set the text values of 5 labels equal to the data in the XML file.
So I a button created in MXML and have set the click event as follows:
click="dsSetup(event)"
I have also declared the following:
public var myRequest:URLRequest = new URLRequest("assets/myFile.xml"); //folder located under src in project
public var myLoader:URLLoader = new URLLoader();
public var myXML:XML;
My function that loads is as follows:
public function dsSetup(event:MouseEvent):void
trace ("dsSetup");
myXML = new XML (myLoader.data);
h3.text = myXML.source.itemA;
h4.text = myXML.source.itemB;
h5.text = myXML.source.itemC;
h7.text = myXML.source.itemD;
h8.text = myXML.source.itemE;
currentState = 'MainMenu';
myLoader.addEventListener(Event.COMPLETE, dsSetup); // I think this line is now redundant as I have set it in the MXML
myLoader.load(myRequest);
This is the way I did it in Flash and it worked ok but I must be missing something in when it comes to Flex.
Can someone explain or point me to a good tutorial that shows how to load XML in Flex?
The ones I found seem to have about 50 lines of code just to load a file and add in way to much complexity for a beginner.
Many ThanksI would suggest to save the loaded data in a Bindable variable and then to bind the text-properties to that:
[Bindable]
var myXML:XML;
public function dsSetup(event:MouseEvent):void
myXML = new XML (myLoader.data);
currentState = 'MainMenu';
<s:Label text="{myXML.source.itemA}"/> -
Need help in Parsing XML Document in Oracle
Hello Experts,
I urgently need your help. We have xml document on the Web but not on the File System. How can I parse the xml document on the web in Oracle.
Any link, blog or sample code would be appreciated.
Your help would be appreciated.
Kind Regards,
Bhavin
London, UKThis breaks down to two issues
1) Getting the XML into Oracle
2) Parsing the XML inside Oracle
For #1, the first two options that come to my mind are httpuirtype and utl_http. Both can be used to get information from a URL that understands HTTP requests.
For #2, you can treat the XML as a DOMDocument or XMLType to parse it. You also could parse it via a SQL statement using XQuery or XMLTable as well.
Many of those examples can be found on the {forum:id=34} forum or [Marco's blog|http://www.liberidu.com/blog/]. A few parsing examples that I've done can be seen at {message:id=3610259}, make sure to also follow the link I put in there to a previous example before that. -
Need help with table, xml files, click actions and visibility
Hi.
I am new to adobe livecycle and I need some guidance in a problem that I am facing.
I have an XML. The main tag 'employee' has 4 tags in it, name, age, ph# and address.
Address tag has 6 more tags in it.
I have to create a table which has 4 columns initially (all text fields). The rows are populated acccording to the XML.
1. S. No., which increments according to row number.
2. Name from XML.
3. Age from XML.
4. ph# from XML.
When any S. No. is clicked on, it should display the address details below that row, when it is clicked on again, it should hide those details and the original table view should be restored.
I googled a lot but am still not able to get how to do this.
Please help.I created a sample for you with what I think you want. Here is a file and the associated XML that goes with it.
Paul -
Parse xml file with validating againat dtd
i have a xlm file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "map.dtd">
<map width="20" height="15" goal="25" name="eXtreme Labyrinth of Dooom">
<random-item type='lantern' amount='5' />
<random-item type='health' amount='10' />
<tile x="14" y="0" type="wall">
<renderhint>wall:rock,cracked</renderhint>
</tile>
<tile x="15" y="0" type="wall" />
<tile x="16" y="0" type="floor">
<renderhint>floor:marble,cracked</renderhint>
</tile>
<tile x="17" y="0" type="floor">
<renderhint>floor:stone,rubble</renderhint>
</tile>
<tile x="18" y="0" type="floor" />
<tile x="0" y="1" type="floor" />
<tile x="1" y="1" type="floor" startlocation="1" />
<tile x="2" y="1" type="floor" />
<tile x="3" y="1" type="floor">
<item type="treasure">Bar of Silver</item>
<renderhint>floor:stone,blood</renderhint>
</tile>
<tile x="4" y="1" type="wall" />
<tile x="5" y="1" type="wall" />
<tile x="6" y="1" type="wall">
<renderhint>wall:bricks,cracked</renderhint>
</tile>
</map>and a dtd document like:
<!ELEMENT map (random-item+, tile+)>
<!ATTLIST map
width CDATA #REQUIRED
height CDATA #REQUIRED
goal CDATA #REQUIRED
name CDATA #REQUIRED
<!ELEMENT random-item EMPTY>
<!ATTLIST random-item
type (armour|health|sword|treasure|lantern) #REQUIRED
amount CDATA #REQUIRED
<!ELEMENT tile (item|renderhint)*>
<!ATTLIST tile
x CDATA #REQUIRED
y CDATA #REQUIRED
type (exit|floor|wall) #REQUIRED
startlocation CDATA #IMPLIED
<!ELEMENT item (#PCDATA)>
<!ATTLIST item
type (armour|health|sword|treasure|lantern) #REQUIRED
<!ELEMENT renderhint (#PCDATA)>i need to validate the xml file against the dtd document and parse it to java using DOM.
Can anyone give ma any suggestions on how to do it?
thank youi have started my coding like:
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import java.io.*;
class loadxml
public static void main(String[] args)
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setIgnoringElementContentWhitespace(true);
DocumentBuilder parser = factory.newDocumentBuilder();
Document doc = parser.parse(new File("hallways.xml"));
loadxml load = new loadxml();
load.parseNode(doc);
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
public void parseNode (Node node) throws IOException
// here is where i have problem with
}since in my xml file, i have got ATTLIST, this ready confuses me when i try to coding it.
Can anyone help me, please.
Thank you.
Edited by: mujingyue on Mar 12, 2008 3:10 PM -
How to compare after parsing xml file
Hi,
following code, parse the input.xml file, counts how many nodes are there and writes the node name and its value on screen.
1) i am having trouble writing only node name into another file instead of writing to screen.
2) after parsing, i like to compare each node name with another .xsd file for existence.
Please keep in mind that, input.xml is based on some other .xsd and after parsing i have comparing its tag with another .xsd
Need you help guys.
thanks
* CompareTags.java
import java.io.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
/** This class represents short example how to parse XML file,
* get XML nodes values and its values.<br><br>
* It implements method to save XML document to XML file too
public class CompareTags {
private final static String xmlFileName = "C:/input.xml";
int totalelements = 0;
/** Creates a new instance of ParseXMLFile */
public CompareTags() {
// parse XML file -> XML document will be build
Document doc = parseFile(xmlFileName);
// get root node of xml tree structure
Node root = doc.getDocumentElement();
// write node and its child nodes into System.out
System.out.println("Statemend of XML document...");
writeDocumentToOutput(root,0);
System.out.println("totalelements in xyz tag " + totalelements);
System.out.println("... end of statement");
/** Returns element value
* @param elem element (it is XML tag)
* @return Element value otherwise empty String
public final static String getElementValue( Node elem ) {
Node kid;
if( elem != null){
if (elem.hasChildNodes()){
for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){
if( kid.getNodeType() == Node.TEXT_NODE ){
return kid.getNodeValue();
return "";
private String getIndentSpaces(int indent) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < indent; i++) {
buffer.append(" ");
return buffer.toString();
/** Writes node and all child nodes into System.out
* @param node XML node from from XML tree wrom which will output statement start
* @param indent number of spaces used to indent output
public void writeDocumentToOutput(Node node,int indent) {
// get element name
String nodeName = node.getNodeName();
// get element value
String nodeValue = getElementValue(node);
// get attributes of element
NamedNodeMap attributes = node.getAttributes();
System.out.println(getIndentSpaces(indent) + "NodeName: " + nodeName + ", NodeValue: " + nodeValue);
for (int i = 0; i < attributes.getLength(); i++) {
Node attribute = attributes.item(i);
System.out.println(getIndentSpaces(indent + 2) + "AttributeName: " + attribute.getNodeName() + ", attributeValue: " + attribute.getNodeValue());
// write all child nodes recursively
NodeList children = node.getChildNodes();
//int totalelements = 0;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
// System.out.println("child value.."+child);
if (child.getNodeType() == Node.ELEMENT_NODE) {
writeDocumentToOutput(child,indent + 2);
if(node.getNodeName() == "DATA"){
totalelements = totalelements+1;}
//System.out.println("totalelements in DATA tag " + totalelements);
/** Parses XML file and returns XML document.
* @param fileName XML file to parse
* @return XML document or <B>null</B> if error occured
public Document parseFile(String fileName) {
System.out.println("Parsing XML file... " + fileName);
DocumentBuilder docBuilder;
Document doc = null;
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setIgnoringElementContentWhitespace(true);
try {
docBuilder = docBuilderFactory.newDocumentBuilder();
catch (ParserConfigurationException e) {
System.out.println("Wrong parser configuration: " + e.getMessage());
return null;
File sourceFile = new File(fileName);
try {
doc = docBuilder.parse(sourceFile);
catch (SAXException e) {
System.out.println("Wrong XML file structure: " + e.getMessage());
return null;
catch (IOException e) {
System.out.println("Could not read source file: " + e.getMessage());
System.out.println("XML file parsed");
return doc;
/** Starts XML parsing example
* @param args the command line arguments
public static void main(String[] args) {
new CompareTags();
}hi,
check out the following links
Check this blog to extract from XML:
/people/kamaljeet.kharbanda/blog/2005/09/16/xi-bi-integration
http://help.sap.com/saphelp_nw04/helpdata/en/fe/65d03b3f34d172e10000000a11402f/frameset.htm
Check thi link for Extract from any DB:
http://help.sap.com/saphelp_nw04s/helpdata/en/58/54f9c1562d104c9465dabd816f3f24/content.htm
regards
harikrishna N -
Hi
Anyone know about support for parsing XML files in LabVIEW?
(I mean specific XML support, I'm familiar with LabVIEWs file functions)
regards
Jan
Sent via Deja.com http://www.deja.com/
Before you buy.I assume you are referring to:
http://www.savarese.org/oro/software/OROMatcher1.1.html
Have you considered asking Savarese?
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com
+1.617.623.5782
WebLogic Consulting Available
"Laurent Mentek" <[email protected]> wrote in message
news:[email protected]..
Hi all,
I'm started to develop with BEA WebLogic and I use ORACLE 8.1.6
database.
We need to map some XML tags as metadata in the database.
Here is a concrete example with part of our XML files:
XML files :
<target>EDU</target>
<question>
<para>
Please could you provide some references on nutritional status in
the frail elderly?
</para>
</question>
I use OROMatcher to parse xml files and it work fine.
I can extract every element in line with success , but don't extract the
value in <para> tag, for example.
I don't no how to use the MULTILINE_MASK option and the ^ or $ to get
this line.
Anyone could give me an example of metadatas extaction using or no the
MULTILINE_MASK option?
Thanks a lot for your help.
Laurent. -
Parsing XML files from application server
I need to read an XML file from the application server. This can be done using OPEN DATASET in BINARY MODE and reading into internal table of type binary data.
But inorder to parse the document using the iXML library, i need to pass the filesize of the XML file that is read into internal table.
Please let me know how to calculate this filesize ?Hi ,
Check the FM : /SAPDMC/LSM_F4_SERVER_FILE.
Inside this FM , subroutine below exists.The main program for routine is /SAPDMC/LLSMW_AUX_020F02.
Call this routine from your program. You will get the length in bytes from the field len of table pt_file.
data:
begin of gs_file,
directory(75) type c, " name of directory.
" (possibly truncated.)
name(75) type c, " name of entry.
" (possibly truncated.)
type(10) type c, " type of entry: directory, file
*len(8) type p, " length in bytes*
owner(8) type c, " owner of the entry
mtime(6) type p, " last modification date,
" seconds since 1970
mode(9) type c, " like "rwx-r-x--x":
" protection mode
errno(3) type c,
errmsg(40) type c,
mod_date type d,
mod_time(8) type c, " hh:mm:ss
subrc like sy-subrc,
end of gs_file.
DATA : pt_file LIKE TABLE OF gs_file.
DATa : p_ok.
PERFORM /sapdmc/llsmw_aux_020f02(directory_contents_get)
TABLES pt_file
USING '/TMP' ""!!! Here is your filepath
CHANGING p_ok -
How to parse XML files from normal FTP Servers?
I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
Who knows how to parse it directly? I Just need to read the contents into a database.
Thanks.I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
Who knows how to parse it directly? I Just need to read the contents into a database.
Thanks. -
How to parse xml file in midlet
Hi Guys,
i wish to parse xml file and display it in my midlet. i found api's supporting xml parsing in j2se ie., in java.net or j2se 5.0. Can u please help me what package to use in midlet?
how to parse xml info and display in midlet? Plz reply soon......Thanks in advance....i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
screenshot -
Hello All,
There is a requirement for parsing of XML files to ABAP.
1.How do we pick an XML file from Application server and also from FTP server?
2.After picking the XML file how to parse that XML file to process it to create material master?Hi,
Ur scenario is File to R/3
For creating material master ..i guess there is IDoc named MATMAS.
U can make use of it and execute File to IDoc Scenario.
link for File to IDoc--
https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/fileToIDOC&
U need to pick XML file from FTP server...No need to parse XML file...just create data type which represents ur xml file structure and map it to IDoc fields.
regards,
Manisha -
When using saxParser.parse(XMLfile, handler) to parse XML file, How to stop the parsing but not exit. I catched thread interrupted in startElement(), but can not stop it because it still go through all other startElement()s and endElement()s. Is there any method or class can stop parse XML?
Appreciate your help!
EdwardPlease look at the technote:
http://access1.sun.com/technotes/01185.html
Hope this helps.
Michelle Cope
Sun Microsystems.
Maybe you are looking for
-
How do i save pictures to icloud
My current I phone 4s is defective. I have received a new one as a replacement. I cannot figure out how to get my old pictures on my new phone. Can I?
-
I'm not sure if I should ask this question on forum but I'm sure someone will gently point it out if it's not allowed. I am about to buy Snow Leopard and will need an external HD or something to back up (clone) my system. With limited finance, what i
-
SP3 not installing with Snow Leopard
I've been trying to reinstall Windows XP partitioned on my new mac along with Snow Leopard. The Service Pack 3 will not install with the XP and many errors pop up. I do have SP2 installed and windows is running fine except when trying to update the s
-
I need quick help!! My iWeb website is not displaying properly on internet explorer. Can you help me?
-
Requisition reference in PDOI - IMPORTANT
All, version: 11.5.10.2 We have a requirement to push the PO's created in a legacy appln to ORacle 11i. Since Oracle has provided standard open interface for PO I decided to use it. Moreover we used Requisition interfaces for req export to oracle. No