Edit the xml using java
Hi friends,
I am having one urgent requirement.I have two xml file name like test1.xml and test2.xml.
I need to delete some contend in test1.xml file.
And also i need to pass value from test2.xml to test1.xml by using java.
i need code for that.
I am very grateful to u if i am getting the answer.
Thanks in Advance,
Hi Fran,
look into this Link
JMS adapter ModuleProcessorException
JMS--> DCJMSStringProperty2 and 1 ?
Similar Messages
-
Read, Modify and Apply Report XML using Java Script
Hi Guys,
Is there any way that we can Pragmatically Read, Modify and Apply Report XML using Java Script or some other way.
Thanks
Kaushik
Edited by: Kaushik K on Jun 20, 2012 8:36 PMRequirement ::
Users should be able to add Column to the Report Dynamically at Runtime.
(There are around 1000+ Users, Answers Approach is not acceptable)
So we are planning to provide a Multi Select / Shuttle Box Option for Users to add Columns dynamically. (Only for Table View)
What we planned to DO ::
Create a Presentation Variable Prompt, Which reads the Metadata Table (Presentation Table.Column Name, populated using the Metadata Dictionary)
And Create a report with One Column and the Column Fx like @{var_dynamic_columns}{'"Time"."Year","Time"."Month"'}
With this, OBIEE is rewriting the Logical SQL Currently as "Select "Time"."Year","Time"."Month" from "A - Sample Sales" "
But getting an error
The number of columns returned in retrieving column metadata was invalid (expected: 1; received: 2)
So we want to see, if we can rewrite the Advanced XML of the Report to have dynamic columns based on the Values from the Presentation Variable.
Please help me if this is a viable solution or any other better solution. -
Merge LiveCycle Form with XML using JAVA
Hello.
I am trying to find out how to merge non-interactive form with XML (using JAVA) so the users can see the final output form with the data filled in.
What are my choices..?
So far, I have created the interactive forms as template using LiveCycle 8 and wrote ASP.NET code to extract data and store it in SQL database when the user fill out and submit the form.
It works great but another agency wants to access the form as well.
They told us that they will create the XML themselves from the database, so they just need to combine the form with XML to display it (non-interactive form).
They want to use JAVA but I am not sure how to do that...
Any suggestion?Assuming that you start with XML in an org.w3c.dom.Document that stores the XML data. Before you can merge it into a form, you have to convert it to a com.adobe.idp.Document object. TO convert a org.w3c.dom.Document to a com.adobe.idp.Document object -- use the following Java code:
private Document convertDataSource(org.w3c.dom.Document myDOM)
byte[] mybytes = null;
try
//Create a Java Transformer object
TransformerFactory transFact = TransformerFactory.newInstance();
Transformer transForm = transFact.newTransformer();
//Create a Java ByteArrayOutputStream object
ByteArrayOutputStream myOutStream = new ByteArrayOutputStream();
//Create a Java Source object
javax.xml.transform.dom.DOMSource myInput = new DOMSource(myDOM);
//Create a Java Result object
javax.xml.transform.stream.StreamResult myOutput = new StreamResult(myOutStream);
//Populate the Java ByteArrayOutputStream object
transForm.transform(myInput,myOutput);
// Get the size of the ByteArrayOutputStream buffer
int myByteSize = myOutStream.size();
//Allocate myByteSize to the byte array
mybytes = new byte[myByteSize];
//Copy the content to the byte array
mybytes = myOutStream.toByteArray();
catch (Exception e) {
System.out.println("The following exception occurred: "+e.getMessage());
//Create a com.adobe.idp.Document object and copy the
//contents of the byte array
Document myDocument = new Document(mybytes);
return myDocument;
THen you can merge myDocument into the Form using renderPDFFOrm:
FormsResult formOut = formsClient.renderPDFForm(
formName, //formQuery
myDocument, //inDataDoc
pdfFormRenderSpec, //PDFFormRenderSpec
uriValues, //urlSpec
fileAttachments //attachments
Hope this helps! -
How to remove xmlns from xml using java
Hi,
<DLList xmlns="http://www.test.com/integration/feed" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Weather>
<StateName>Karnataka</StateName>
<ForecastName>Bagalkote</ForecastName>
<Humidity>89.9</Humidity>
</Weather>
<Weather>
<StateName>Karnataka</StateName>
<ForecastName>Devengiri</ForecastName>
<Humidity>89.9</Humidity>
</Weather>
</DLList>
The above xml needs to be decomposed using xsu.I am facing a small problem because the xml has namespaces.
How to remove the namespace using java to get the below xml
Note:I am using XSLT for the transformation.The XSLT tag is not identifying the <DLList> tag with name space
<DLList>
<Weather>
<StateName>Karnataka</StateName>
<ForecastName>Bagalkote</ForecastName>
<Humidity>89.9</Humidity>
</Weather>
<Weather>
<StateName>Karnataka</StateName>
<ForecastName>Devengiri</ForecastName>
<Humidity>89.9</Humidity>
</Weather>
</DLList>
Please help.Let me know if any other information is required
ThanksOK, here goes :
For the example, I'll use a TB_DISTRICT table with the following structure :
create table tb_district (
sr_no number(3),
district_name varchar2(100)
);loaded with data from this page :
http://india.gov.in/knowindia/districts/andhra1.php?stateid=KA
and this XML document (one additional record compared to the one you posted) :
<DLList xmlns="http://www.test.com/integration/feed" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Weather>
<StateName>Karnataka</StateName>
<ForecastName>Bagalkote</ForecastName>
<Humidity>89.9</Humidity>
</Weather>
<Weather>
<StateName>Karnataka</StateName>
<ForecastName>Devengiri</ForecastName>
<Humidity>89.9</Humidity>
</Weather>
<Weather>
<StateName>Karnataka</StateName>
<ForecastName>Dharwad</ForecastName>
<Humidity>70.1</Humidity>
</Weather>
</DLList>In order to access the XML, I'll also use this Oracle directory object :
create directory test_dir as 'D:\ORACLE\test';Final relational tables are :
create table BUSINESS_TABLE
STATE VARCHAR2(30),
DISTRICT_NAME VARCHAR2(30),
HUMIDITY NUMBER
);and
create table REJECT_TABLE
STATE VARCHAR2(30),
DISTRICT_NAME VARCHAR2(30),
HUMIDITY NUMBER,
ERROR_MESSAGE VARCHAR2(500)
);With XMLTable function, we can easily break the XML into relational rows and columns ready to use for DML :
SQL> alter session set nls_numeric_characters=". ";
Session altered
SQL>
SQL> SELECT *
2 FROM XMLTable(
3 XMLNamespaces(default 'http://www.test.com/integration/feed'),
4 '/DLList/Weather'
5 passing xmltype(bfilename('TEST_DIR','test.xml'), nls_charset_id('CHAR_CS'))
6 columns
7 state varchar2(30) path 'StateName'
8 , district_name varchar2(30) path 'ForecastName'
9 , humidity number path 'Humidity'
10 )
11 ;
STATE DISTRICT_NAME HUMIDITY
Karnataka Bagalkote 89.9
Karnataka Devengiri 89.9
Karnataka Dharwad 70.1
Then with a multitable insert, we load both the business table and the reject table (if the district name does not exist in TB_DISTRICT) :
SQL> INSERT FIRST
2 WHEN master_district_name IS NOT NULL
3 THEN INTO business_table (state, district_name, humidity)
4 VALUES (state, district_name, humidity)
5 ELSE INTO reject_table (state, district_name, humidity, error_message)
6 VALUES (state, district_name, humidity, 'Invalid district name')
7 WITH xml_data AS (
8 SELECT *
9 FROM XMLTable(
10 XMLNamespaces(default 'http://www.test.com/integration/feed'),
11 '/DLList/Weather'
12 passing xmltype(bfilename('TEST_DIR','test.xml'), nls_charset_id('CHAR_CS'))
13 columns
14 state varchar2(30) path 'StateName'
15 , district_name varchar2(30) path 'ForecastName'
16 , humidity number path 'Humidity'
17 )
18 )
19 SELECT x.*
20 , t.district_name as master_district_name
21 FROM xml_data x
22 LEFT OUTER JOIN tb_district t ON t.district_name = x.district_name
23 ;
3 rows inserted
SQL> select * from business_table;
STATE DISTRICT_NAME HUMIDITY
Karnataka Dharwad 70.1
SQL> select * from reject_table;
STATE DISTRICT_NAME HUMIDITY ERROR_MESSAGE
Karnataka Bagalkote 89.9 Invalid district name
Karnataka Devengiri 89.9 Invalid district name -
Customizing Flash Galleries by editing the XML
The controls within the Web tab allow you to customize the Lightroom Flash Gallery templates in a lot of ways. However, you can customize them much further by editing the XML files that are generated when you export a gallery. This requires almost no knowledge of Flash or HTML, and can be done with almost any text editor.
Here are few examples of what you can do:
Add a background image
Turn off (hide) the Title Bar and/or Menu Bar
Change the width, transparency, and color of borders around thumbnails and images
Turn thumbnail and image drop shadows on/off
Change the transition between images, including straight cut
Change image and transition durations
Change the color and transparency of all parts of a gallery including image and thumbnail area backgrounds and borders, individual buttons parts, scroll bar parts, etc
Change the height of the captions display area
Change text fonts and sizes
And much more
To start playing with this, simply open the style.xml file found within an exported gallery inside the ..resources/styles folder. You can also preview the gallery by double clicking on the index.html file, then make changes to the style.xml file in your text editor, save, and then refresh your browser to see the effect. Once youve achieved the look you want, you can copy your edited style.xml file into any gallery you export.
Note: any text editor will work, but using an app that has good HTML or XML editing features (Adobe Dreamweaver for example) will make it much easier.
Ive posted a few tips and tricks articles about how to do this on our blog at http://blog.bluefire.tv and plan to add more from time to time.gsimpson,
There is no way via the XML to change the behavior where the smallest rendition will scale down to fit the window. Since the gallery itself scales to fit the window, scroll bars would need to appear on the image itself if the window is too small. This is in fact the behavior of the galleries in B4 if I remember correctly, but there is no way to achieve that with the 1.0 version.
However, you can achieve your goal with a bit of html work. One easy way it to "fix" the size of your gallery within your web page (by using pixel values in the embed code for example) such that it is set big enough that the smallest rendition will not be scaled.
Or, if you can do fairly advanced HTML you could let your gallery scale up, but not below a certain size. To do that, you'd need to put the gallery inside a "container" within your html page, (e.g a div or table cell) and then limit how small that container can be, and make sure that the container itself will grow to fill the available space.
Another alternative would be to make your own "small" renditions, that are so small that they will not scale at the gallery's minimum size. Speaking of minimum size of the gallery, wouldn't it be nice if you could set that? Who knows, maybe someone will contribute that code to the AMG open source project... -
How to create a table in the file using java code.?
HI,
I should export the data from the view objects to a word document. I have done that but I should
display the data in the form of a table.
Kindly come up with the necessary information on how to create a table in the file using java.
Thanks,
PhaniHi, Thank you for responding to my query.
The below are the details of my code.
DCBindingContainer dcBindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding StudentDetailsContent =
(DCIteratorBinding)dcBindings.get("StudentView1Iterator");
OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
Row currentRow =
StudentDetailsContent.getRowSetIterator().first();
Object a[]= currentRow.getAttributeValues();
int i;
for(i=0 ;i<=a.length;i++){
w.write(a.toString());
w.write(" ");
w.flush();
I am usning this coding to achieve the task of exporting data to file.
I need to display this information in the table that is where I need help from you people.
Thanks, -
Code for reading the and placing the file using java webservice
Hi All,
Can anybody can guide me on how to read a file and place the file using java.
Let me know if any code is available which has been completed using java.
Regards,
RahulHi,
The "square" symbol that you are referring to is probably a CRLF (Carriage Return - Life Feed) Control Character.
This is more commonly known as a "Enter" at the end of a line / sentence.
To clean this character from strings in Java, please use:
String patternStr = "(?m)$^|[\\r\\n]+\\z";
String replaceStr = " ";
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
return matcher.replaceAll(replaceStr);
Hope that helps.
Thanks.
p256960. -
Who can introduce the development contents of the project using java ?
Hi , Web Dynpro experts:
Could u introduce the working contents of the project using java ?
1. Do you develop function that would run in a sap standard system(such as CRM ,internet sales)? OR develop a completely independent web application base on client's demand(EJB,JSP,HTML)?
2.Do all the user interfaces run in web browser ?
In a word ,I just want to know what picture is it as you are using java to work on SAP ,Because I must study AP&JAVA duo to the coming project. Could you explain it for me about SAP&JAVA in any perspective according to your project experience .
BTW: I have 2 years experience on J2EE and 1 year on ABAP. So how i should get started ?Hi Guixin,
The most common structure for building a WebDynPro application is to expose functionality from underlying systems and present it using the WebDynPro UI. Often the underlying system is a SAP ERP/CRM type system, but can also be any WebService compliant system, or a combination of both.
Using the Netweaver System Landscape Directory (SLD), WebDynPro can send and receive data independantly of the source. SAP ERP/CRM systems will expose their functionality using RFC-enabled BAPIs. These functions can be standard SAP delivered modules or custom developed using ABAP.
The choice of where to develop your business logic really depends on the history/strengths of your organisation. If you have a strong history of ABAP development in SAP, then it would be recommended to use ABAP for your business logic and WebDynPro for UI. If J2EE is the strong suit, use that instead.
The WebDynPro interface runs in a browser (either IE or Firefox) however there is a beta version of a WebDynPro GUI for Windows which may offer some performance improvements.
HTH,
Jonathan -
How To Update The Registry using Java
I want to open up the registry and place my Java Application in the Startup using Java.Opening the Registry is done with the use of Exec() now how to add my program in the startup.
Tx in Advance.
gomesSearch the forum - I've already answered similar questions about 10 times.
-
How to Edit the xml node value using flex from the front end UI
Hi All,
I am having a use case with flex 4.6
1> To read the external xml file
2> Display the tree structure in the front end UI
3> Edit the node values of the xml file from the front end UI and save it back
How to go about the above use case, any blogs or links on the above case will be help
Thanks,
AlokCheck this is example:
http://blog.flexexamples.com/2009/07/23/deleting-nodes-from-an-xml-object-in-flex/ -
Problem in evaluating the xpath in xml using java.
Hi ,
I have written a method to evaluate the xpath, and will return the result as string 'true' or 'false' or 'anyValue as in the xpath'
eg:
<k>
<g>1</g>
<c>!</c>
</k>
<k>
<g>2</g>
<c>#</c>
</k>
<k>
<c>$</c>
</k>
if the xpath is /k[g/text()='1']/c/text()='#' --- this code returns false
similarly /k[g/text()='1']/c/text()='!' -- this returns true
But in the flow of my project, we have removed the xml nodes which has no data. so , the last <k> tag is not having <g>. so , wat i expect is
if the xpath is /k[g/text()='']/c/text()='$' should return true. but since, there is no <g> tag, it is returning false. But, by logic of my project, g is there, but removed bcz its null..
Pls help me in this regard..
Thanks,
Sabarisri. N
Edited by: Sabarisri N on Nov 11, 2011 4:33 PM
Edited by: Sabarisri N on Nov 11, 2011 4:35 PMThe criteria for the return true or false is not clear as all three instances are that specific. To accommodate these three instances, the xpath can be very restrictive in the look like this. For illustration, I put it in a xsl:if or xsl:when node testing use, supposing the context node be the parent of k node.
<xsl:if test="k[(normalize-space(c)='!' and normalize-space(g)='1') or
(normalize-space(c)='#' and normalize-space(g)='2') or
(normalize-space(c)='$' and not(g))]">Since the conditions are that specific, it inevitably looks clumsy due to the need of enumerating case-by-case! -
How to generate XML usng java without using following.
import org.apache.xerces.dom.DocumentImpl;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
XML to be generated is as follows.
<?xml version="1.0" encoding="UTF-8"?>
<Modi xmlns:xsi="Modi/Modi1">
<docConfig>
<className>PO</className>
<classDesc>Purchase</classDesc>
<create>Y</create>
</docConfig>
<indexConfig>
<index sequence="1">
<shortName>PODATE</shortName>
<displayName>PO Date</displayName>
<type>date</type>
<length>10</length>
</index>
</indexConfig>
</upload>Two answers.
If you want to not use any of the XML-oriented classes, you can use a PrintWriter. Just code:
PrintWriter pw = new PrinteWriter(whatever);
pw.println( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );
etc.If you want to use XML-oriented classes, but just not these 3 (can't imagine why), then use
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
instead of XMLSerializer and OutputFormat, and
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
instead of the DocumentImpl
Dave Patterson -
hi
i am trying to parse a document and change a specific text value within an element althouh when i run the program it changes the nodes text however when i check the xml file it doesnt show the changes it remains the same the code that i am using is as follow iwould be greatful if any one culd help:
// ReplaceText.java
// Reads intro.xml and replaces a text node.
// Java core packages
import java.io.*;
// Java extension packages
import javax.xml.parsers.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.dom.*;
// third-party libraries
import org.xml.sax.*;
import org.w3c.dom.*;
public class ReplaceText {
private Document document;
public ReplaceText()
// parse document, find/replace element, output result
try {
// obtain default parser
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
// set parser as validating
factory.setValidating( true );
// obtain object that builds Documents
DocumentBuilder builder = factory.newDocumentBuilder();
// set error handler for validation errors
builder.setErrorHandler( new MyErrorHandler() );
System.err.println( "reading" );
// obtain document object from XML document
File f = new File("D:/Documents and Settings/Administrator/Desktop/xml adv java bk/appC/intro.xml");
System.err.println( "reading" );
document = builder.parse(f);
//document = builder.parse( new File( "intro.xml" ) );
System.err.println( "reading document" );
// retrieve the root node
Node root = document.getDocumentElement();
if ( root.getNodeType() == Node.ELEMENT_NODE ) {
Element myMessageNode = ( Element ) root;
NodeList messageNodes =
myMessageNode.getElementsByTagName( "message5" );
if ( messageNodes.getLength() != 0 ) {
Node message = messageNodes.item( 0 );
System.out.println("iiiii");
// create text node
Text newText = document.createTextNode(
"New Changed Message!!" );
// get old text node
Text oldText =
( Text ) message.getChildNodes().item( 0 );
// replace text
//message.removeChild(oldText);
message.replaceChild( newText, oldText );
// output Document object
// create DOMSource for source XML document
Source xmlSource = new DOMSource( document );
// create StreamResult for transformation result
Result result = new StreamResult( System.out );
// create TransformerFactory
TransformerFactory transformerFactory =
TransformerFactory.newInstance();
// create Transformer for transformation
Transformer transformer =
transformerFactory.newTransformer();
transformer.setOutputProperty( OutputKeys.INDENT, "yes" );
transformer.setOutputProperty( OutputKeys.STANDALONE, "yes" );
// transform and deliver content to client
transformer.transform( xmlSource, result );
// handle exception creating DocumentBuilder
catch ( ParserConfigurationException parserException ) {
parserException.printStackTrace();
// handle exception parsing Document
catch ( SAXException saxException ) {
saxException.printStackTrace();
// handle exception reading/writing data
catch ( IOException ioException ) {
ioException.printStackTrace();
System.exit( 1 );
// handle exception creating TransformerFactory
catch (
TransformerFactoryConfigurationError factoryError ) {
System.err.println( "Error while creating " +
"TransformerFactory" );
factoryError.printStackTrace();
// handle exception transforming document
catch ( TransformerException transformerError ) {
System.err.println( "Error transforming document" );
transformerError.printStackTrace();
public static void main( String args[] )
ReplaceText replace = new ReplaceText();
}the xml file that i am using is as follows:
<?xml version = "1.0"?>
<!-- Fig. 28.10 : intro.xml -->
<!-- Simple introduction to XML markup -->
<!DOCTYPE myMessage [
<!ELEMENT myMessage (message, message5)>
<!ELEMENT message (#PCDATA)>
<!ELEMENT message5 (#PCDATA)>
]>
<myMessage>
<message>welcome to the xml shhhhhushu</message>
<message5>welcome to the xml shhhhhushu</message5>
</myMessage>i would be greatful if some one could please help.....See if the Text 'oldText' actually has any text within it. Sometimes in DOM parsing, you will get something like:
Element
Text (blank)
Text (actual)
Text (blank)Whereas you would expect to receive:
Element
Text (actual)See if that is the case. If yes, modify your logic to iterate through the child text nodes until one with actual text inside of it (getNodeValue()) is found.
- Saish -
Query resultset to xml using java and XML schema
Hi,
I query data using JDBC and I want to store it to an XML file which has a well defined XML schema. I searched a lot in the forum but did not find an answer. Please guide me to create this program.
I have managed to use JDBC to get result set but I do not know how to export is to XML using XSD and Java.
Please help.
Regards,
RaviI have managed to use JDBC to get result set but I do
not know how to export is to XML using XSD and Java.Export using XSD? Schemas are for validation.
Iterate through the result set, and build up the XML stream by creating an entry for each row.
Another way to do it is to load the ResultSet into a Java object and serialize that to XML using something like XStream.
% -
I want to read all <temp >nodes map them to some variable and create one more XML.
I am stuck up in the first place itself where i need to read the data :( . I am getting null pointer exception, please find the code also.
<?xml version="1.0" encoding="UTF-8"?>
<ftpl id="47" name="XXXXXXXX xxx xxxxxxxx">
<abc-cab name="Systems" id="43434">
<abc-dr name="zzzzz" id="4545454">
<temp key="Type">null</param>
<temp key="Folder">/ZVZ/XXXXX - xyz</param>
<temp key="Author">XYZ,ABC</param>
<temp key="Comments">null</param>
<temp key="Mailed_By">XYZ,ABC</param>
<temp key="Subject">null</param>
<temp key="Key_Words">null</param>
<abc-page name="1" id="3524012">
<file text="/asas/asasa/asa/asas/Oxxxxxx2276744.txt" count="1"/>
</abc-page>
</abc-dr>
</abc-cab>
</ftpl>
try {
File file = new File("source-file");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file);
doc.getDocumentElement().normalize();
System.out.println("Root element " + doc.getDocumentElement().getNodeName());
NodeList nodeLst = doc.getElementsByTagName("abc-dr");
for (int s = 0; s < nodeLst.getLength(); s++) {
Node fstNode = nodeLst.item(s);
if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
Element fstElmnt = (Element) fstNode;
NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("abc-dr");
Element fstNmElmnt = (Element) fstNmElmntLst.item(1);
NodeList fstNm = fstNmElmnt.getChildNodes();
System.out.println("First Node : " + ((Node) fstNm.item(1)).getNodeValue());
NodeList lstNmElmntLst = fstElmnt.getElementsByTagName("Folder");
Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
NodeList lstNm = lstNmElmnt.getChildNodes();
} catch (Exception e) {
e.printStackTrace();
Please help.. let me know the code which read XML I have tried with all SAX/DOM i am getting same NUllPointerExcetion
Message was edited by:
JavaNewUserHi
Thanks patricknz
pls find the XMl and the java code
I have again modified the code .. but got the same result as below
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[abc-page: null]----------------------abc-page=
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
import java.lang.*;
public class SampleDOM
public static void main(String s[]){
try{
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = docBuilder.parse("C:\\demo.xml");
NodeList nodeList = document.getElementsByTagName("abc-dr");
for (int i = 0, length1 = nodeList.getLength(); i < length1; i++) {
final Element rDoc = (Element)nodeList.item(i);
final NodeList rDocC = rDoc.getChildNodes();
for (int j = 0, length2 = rDocC.getLength(); j < length2; j++) {
final Node child = rDocC.item(j);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)child;
System.out.println(element.getChildNodes() + "----------------------" +
new StringBuffer(element.getNodeName()).append(" = "));
}catch(Exception e){
e.printStackTrace();
}XML FIle:-
<?xml version="1.0" encoding="UTF-8"?>
<ftpl id="47" name="XXXXXXXX xxx xxxxxxxx">
<abc-cab name="Systems" id="43434">
<abc-dr name="zzzzz" id="4545454">
<temp key="Type">null</param>
<temp key="Folder">/ZVZ/XXXXX - xyz</param>
<temp key="Author">XYZ,ABC</param>
<temp key="Comments">null</param>
<temp key="Mailed_By">XYZ,ABC</param>
<temp key="Subject">null</param>
<temp key="Key_Words">null</param>
<abc-page name="1" id="3524012">
<file text="/asas/asasa/asa/asas/Oxxxxxx2276744.txt" count="1"/>
</abc-page>
</abc-dr>
</abc-cab>
</ftpl>Message was edited by:
JavaNewUser
Message was edited by:
JavaNewUser
Maybe you are looking for
-
Hi, I am New to EDI-IDocs,We have a requirement over here to send the iDocs from SAP to Non-SAP sys(JCAPS). Need step-by-step details to convert the iDoc to EDI format. Helpfull Answers will b Rewarded. Regards Giridhar Reddy
-
Deleted node SMTP in TCode Scot
hello everyone!!! I need help solving a problem. This is that while trying to configure SMTP in the "TCode SCOT" they eliminated nodes "SMTP" when trying to create a new tells me "STMP node already exists." It is possible to re-create the "SMTP 'or c
-
Hi,I installed essbase server to my desktop from licensed CD .. installation went smooth .. server is ready to take client request ..but when I tried to connect this server from Essbase Application Manager of this server machine itself .. it gave me
-
I changed out my old cell phone for a Motorola zoom and now the zoom has my old phone number associated with it's sim card. I just purchased a Samsung Android cell phone and would like to trade the sim from my new to cell to the zoom so I can have my
-
Puedo acercarme a un ipoint a qué cambien esta batería por una nueva gratuitamente?