Help in DOM

Hi,
I am generating a XML using DOM (org.w3c.dom ) which holds the form values.
The XML schema is like this
<root>
<data>
<id>1</id>
<check>True</check>
</data>
<data>
<id>2</id>
<check>false</check>
</data>
</root>
What im doing in my code -
I/P : Request parameter Values obtained from FORM
o/p: XML String
1)Create a root node
2)Create a Node called data
3)Create an id node and set the value obtaining from the Request parameter. Then append this node to data node
4)Similary create the check node,set its value based on some calculation and append this to data node.
5) Then attach the data node to Root node
Finally attach the Root node to the Document and later i convert this Documemt to String using serialization.
Problem here is sometimes based on Request parameter value, i want to check the id node created already and compare with the request value. If it matches, then i have to append a new node in the data node something like this :
Request value is 2 and ID node value is 2. hence append a new node
<data>
<id>2</id>
<check>false</check>
<newnode>test </newnode>
</data>
But how can i get the ID node,check its value ,compare with the request value and if it matches attache a new node as the Document at this point of time is not yet constructed. ie The data nodes are keep on attached to the root node and only finally the root node is attached to the Document.
Could anyone please help how to solve this problem . Please ask me if you are not clear.
Thanks in advance

Why don't you create a blank DOM document and than add root node and other nodes?
http://www.roseindia.net/xml/dom/

Similar Messages

  • Need Help On DOM

    i have learned SAX n DOM parsing in java but not sure about how to use in it my jsp n Servlet project , how it helps me to gain performance plz help

    i have learned SAX n DOM parsing in java but not sure
    about how to use in it my jsp n Servlet project , how
    it helps me to gain performance plz helpWhy would you want to use it in your project? Do you have to process XML ? Why?

  • HELP: Using DOM in J2ME

    I'm trying to use DOM in J2ME, but I'm unable to find a API that has a documentFactory. Can anyone help me?

    "I'm using J2ME" isn't very informative, because there are a number of basic J2ME APIs, called profiles. For mobile phones it's generally MIDP (1.0 or 2.0); for devices like PocketPC it's as likely to be FP (Foundation Profile), PBP (Personal Basis Profile), or PP (Personal Profile), again having multiple versions.

  • Help with DOM Parser

    Hello! I am writing a JRXML file with XML extension and trying to parse using DOM Parser.But I am getting the following Exception:
    java.net.UnknownHostException: jasperreports.sourceforge.net
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at sun.net.NetworkClient.doConnect(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.<init>(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
         at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
         at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
         at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
         at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
         at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
         at net.zycomm.reportGeneration.source.WriteJrxml.<init>(<myfilename.java>.java:44)
         at net.zycomm.reportGeneration.source.WriteJrxml.main(<myfilename.java>).
    I need another answer:How can I parse a JRXML file?

    it is a network problem, I think the DNS of your provider is not up to date so it cannot find the domain.
    There must be a schema declaration at the beginning of your JRXML file. It points to a schema situated on the jasper site (which has changed recently).
    The better turnaround is to find this schema, place it on your local file system (or in server's hierarchy) and to change the schema definition in the jrxml file to point to the local file

  • Need help with DOM

    I got the following code from the Java DOM walkthrough. I am trying to enhance it. I want to build an XML file with my DOM. and then right the new XML to a file. I want to learn how to do it. It's not about being efficient.
    How do I add child elements to this with child tags and then give them values? If you look at the code, it creates a root, then appends a 'child', but I don't see how its giving the child an element name. it just looks like its giving it a value.
       public static void buildDom()
            DocumentBuilderFactory factory =
               DocumentBuilderFactory.newInstance();
            try {
              DocumentBuilder builder = factory.newDocumentBuilder();
              document = builder.newDocument();  // Create from whole cloth
              Element root =
                      (Element) document.createElement("rootElement");
              document.appendChild(root);
              root.appendChild( document.createTextNode("Some") );
              root.appendChild( document.createTextNode(" ")    );
              root.appendChild( document.createTextNode("text") );
            } catch (ParserConfigurationException pce) {
                // Parser with specified options can't be built
                pce.printStackTrace();
        } //

    If you're looking to build up simple documents, Dom4J might be your best choice: http://www.dom4j.org/
    Combining two examples from their Quick Start guide, here's the code to do what you want (note: it hasn't been compiled, just copied from the Dom4J website with some strings changed):
    import org.dom4j.Document;
    import org.dom4j.DocumentHelper;
    import org.dom4j.Element;
    import org.dom4j.io.OutputFormat;
    import org.dom4j.io.XMLWriter;
    public class Foo {
        public Document createDocument() {
            Document document = DocumentHelper.createDocument();
            Element root = document.addElement( "root" );
            Element value1 = root.addElement( "value1" )
                .addText( "myVal " );
            Element author2 = root.addElement( "value2" )
                .addText( "myVal2" );
            return document;
    public void write(Document document) throws IOException {
            // Pretty print the document to System.out
            OutputFormat format = OutputFormat.createPrettyPrint();
            writer = new XMLWriter( System.out, format );
            writer.write( document );
    }

  • Simple help with DOM parsing - urgent

    hi,
    i'm new to xml parsing and have a simple (i think) question.
    i have the following xml
    <record>
    <header>
    <id>1</id>
    </header>
    </record>
    <record>
    <header>
    <id>1</id>
    </header>
    </record>
    i'm trying to parse first the records then from a record parse the header and from it get the id in the following way:
    NodeList nodeList = org.apache.xpath.XPathAPI.selectNodeList(doc, "//*[name() = 'record']");
    for every element i in the nodeList
    Node node1 = nodeList.item(i);
    Node node2 = org.apache.xpath.XPathAPI.selectSingleNode(node, "//*[name() = 'header']");
    Node node3 = org.apache.xpath.XPathAPI.selectSingleNode(node2, "//*[name() = 'id]");
    String id = node3.getFirstChild().getNodeValue();
    even due i run in a loop and i see node1 containing the right record the other parsing gives me the always the data of the first record.
    can't i parse and then re-parse on the node i got?
    if the second parsing always done from the root, even due i gave the parser another node?
    what am i doing wrong?
    thanks in advance
    alon

    Your xpath & everything else looks right. I have 2 questions...
    1 -- what is the length of NodeList nodeList = org.apache.xpath.XPathAPI.selectNodeList(doc, "//*[name() = 'record']"); ?
    The answer should be 2, you have 2 record from the XML
    2 -- both id of your record is 1. Are you seeing the same value returned because of this? What do you see if you change the second record's id to 2 ??

  • Creating XML String DOM

    Hi ppl,
    I need some help with DOM Object. I have a xml file which I parse with dom and when I do some changes in dom object like adding new element or changing the values of existing object and now when I try to transorm the dom object back to a xml string. It puts everything in one line. for example say my xml file is like:-
    <student>
        <name>john</name>
        <result>pass</result>
    </student>Now when I add new element <address> to it , change value of existing element and try to get xml string i get something like this
    <student><name>smith</name><address>412Miam</address><result>pass</result></student>
    Whole xml in one or two lines, instead of proper xml with one element and its value in one line.
    Any ideas how to achieve this?

    Ddosot,
    Thank you very much. I was looking for this from long time.
    Honeslty I have searched news group many times but couldnt get an answer, may be my search words were not correct.
    you could have saved all this writing by running a
    little search on this forum, as this questions is
    asked once per day.
    anyway, here is your answer:
    transformer.setOutputProperty(OutputKeys.INDENT,
    "yes");
    transformer.setOutputProperty("{http://xml.apache.org/x
    lt}indent-amount", "1");

  • Running a java program in another java code

    Hello,
    I have a question.I wrote a java server code named server.java. In this server code, I receive another java class code called "HelloWorld.class" from another node. What I want to do is to execute the class HelloWorld inside server.java.
    Briefly, I would like to run a compiled java code (class code)in another executing class code. How can I achieve this?
    Thanks in advance
    �ebnem Bora

    Hi,
    Sorry but your terminology isn't that clear. Are you trying:
    1. To call methods on another class or
    2. To launch a separate process that will run another class?
    If it's either of these then they're not 'Advanced Language Topics' but simple:
    // Scenario 1
    // in Server class
    HelloWorld hw = new HelloWorld();
    hw.sayHello(); // or whatever the method is
    // Scenario 2
    Runtime.exec(new String [] {"java", "HelloWorld"}); // or whateverIs that of any help?
    Dom.

  • Adding a javascript img array file to picture in dreamweaver

    Hi I am very new to Javascript but efficient in Dreamweaver. I use CS5 and a Macbook Pro. I'm trying to attach a Javascript file to a picture on my homepage. I wrote the code in text edit and saved it as an HTM file. When I open the file in Google Chrome, Safari or Firefox it works perfectly and the array displays all five pictures in a row. How do I attach this to dreamweaver? Also do I leave in the HTML tags in the javascript file? Here's how it looks when it plays right on a browser.
    <HTML>
    <HEAD>
    <TITLE>Please Work</TITLE>
    <SCRIPT>
    var imgArray = new Array(5);
    imgArray[0] = new Image;
    imgArray[0].src = "awesome.jpg";
    imgArray[1] = new Image;
    imgArray[1].src = "dadinforest.jpg";
    imgArray[2] = new Image;
    imgArray[2].src = "neatplant.jpg";
    imgArray[3] = new Image;
    imgArray[3].src = "greenlake.jpg";
    imgArray[4] = new Image;
    imgArray[4].src = "cattail.jpg";
    var index = 0;
    function cycle()
          document.banner.src = imgArray[index].src;
          index++;
          if (index == 5)
               index = 0;
          setTimeout("cycle()", 3000);
          return;
    </SCRIPT>
    </HEAD>
    <BODY onLoad="cycle()">
    <CENTER>
    <IMG NAME="banner" SRC="awesome.jpg">
    </CENTER>
    </BODY>
    </HTML>

    Kitty Collins3 wrote:
    I'm trying to attach a Javascript file to a picture on my homepage. I wrote the code in text edit and saved it as an HTM file. When I open the file in Google Chrome, Safari or Firefox it works perfectly and the array displays all five pictures in a row. How do I attach this to dreamweaver?
    What you have created is an HTML file with a block of JavaScript in the <head>. It's not a JavaScript file, so there's nothing to attach. Just put the <script> block in the <head> of the page where you want to use it, and make sure your image is named "banner".
    If you're just starting to learn JavaScript, you should be aware that JavaScript practices have changed radically in the past few years. Looking at the code you have written, it seems as though you are using an old book or an online script that was written many years ago. Several clues are the uppercase characters in the HTML tags, the <center> tag, the name attribute in the <img> tag, and the use of a string as the first argument to setTimeout().
    JavaScript can be quite difficult to master, so make sure you learn from a reliable, modern source. A book that I found very helpful is DOM Scripting by Jeremy Keith. A new edition of the book was published this week (http://friendsofed.com/book.html?isbn=9781430233893). I'm sure there are other good resources, but you should avoid anything written earlier than 2005.

  • How to Map XML data with XSD Schema in JAXB

    Hello,
    I am very much new to JAXB.
    I am in need of someone help to go further in my dev.
    I am having an XSD and i could able to do marshall and unmarshall using JAXB.
    My problem is...
    Consider followings are my Schema...
    - <person id="general" help="USER.DOM.HELP.GENERAL" label="USER.DOM.LABEL.GENERAL" access="READWRITE">
    <attribute id="Name" mandatory="true" type="STRING" access="READONLY" widget="NONE" />
    <attribute id="login" label="USER.LABEL.LOGIN" help="USER.HELP.LOGIN" regexp="[A-a]" type="STRING" summary="true" access="WCREATE_RUPDATE" widget="TEXTFIELD" />
    <attribute id="firstname" summary="true" label="USER.LABEL.FIRSTNAME" help="USER.HELP.FIRSTNAME" type="STRING" regexp="[A-a]" access="READWRITE" widget="TEXTFIELD" />
    In this example a person contains set of attributes... some are mandatory(Name)...
    In my application i will unmarshall the the schema file and show in GUI as a set of attributes when the operator want to create a person. And its very well working.
    Now say for example, i am requesting my server to show all the created persons and its showing. when i click on the particular person the GUI will place the request to the server to get the corresponding date for the selected person.
    But the response contains only the mandatory attribute.. i mean Name.... this may be because of the way my server working. So now i want to show the operator all the set of attributes for that person with the Name.
    I mean i need to merge the schema with me resultant data and show it in the GUI.
    My result is in the form of xml stream. And i will convert my schema also in the form of XML...
    Now i need to merge both of this XMl and need to present in the GUI...
    Any help please...
    Thank You!!!

    Still i am not getting any reply :(

  • Plugin-container over load cpu

    ever since the update with the plugin-container most videos stop and start. my cpu usage pegs at 100. when I shut down plugin-container everything go to normal except vids shut down. can this be removed or do I need to get a different browser. everything was fine untill update. my wifes computer was having the same problem so she switched to chrome and fixed her problem. I'm thing of doing the same.

    http://kb.mozillazine.org/Plugin-container_and_out-of-process_plugins
    Try to disable IPC.
    You can set the prefs dom.ipc.plugins.enabled.* to '''false''' on the about:config page to disable the plugin-container process to see if that helps.
    '''dom.ipc.plugins.enabled.npswf32.dll''' (Flash)
    '''dom.ipc.plugins.enabled.npctrl.dll''' (Silverlight)
    '''dom.ipc.plugins.enabled.npqtplugin.dll''' (QuickTime)
    To open the ''about:config'' page, type '''about:config''' in the location (address) bar and press the Enter key, just like you type the url of a website to open a website.
    If you see a warning then you can confirm that you want to access that page.
    Double-click each of those prefs to toggle them to false, then restart Firefox.

  • Convert XML values to internal table

    Hi Experts
    How can i convert XML values to internal table . i am getting all the values into the string.
    this is my example
    <?xml version="1.0" encoding="UTF-8"?><TEST><ZTEST><DEPTNO>HEADOFFICE</DEPTNO><DNAME>IT</DNAME><LOC>HYD</LOC><MANDT>003</MANDT></ZTEST></TEST>
    i did create internal table with 4 fields.
    Please help.

    XML DOM Processing in ABAP part I -  Convert an ABAP table into XML file using SAP DOM Approach.

  • Set tcp ip debug issue! doesn't log!

    Hi,
    I have tried to debug tcp ip traffic but the usual logging doesn't
    work.
    I set the debugger to 1
    use the net
    set it to 0
    unload conlog
    view the conlog file
    but it doesn't show any traffic at all.
    Only logs the commands executed on system screen.
    currently NW 6.0 sp3 on both servers (BM + fileserver)
    Tried to find something on it on Craigs site but there was a
    mentioning
    from last year that it had a bug that should be fixed with sp1
    Help apriciated,
    Dom
    Dominicus B
    architect
    Finland
    www.abrakadabra.fi
    Sent using Virtual Access 5.51 - download your freeware copy now
    http://www.atlantic-coast.com/downloads/vasetup.exe

    In article <[email protected]>, DomincusB wrote:
    > Save the screen to a file?
    >
    Yes, press F1 on the logger screen and see the help content. F2
    should
    save to a file. With the latest patches for NetWare, you can specify
    the file location and name as well.
    Craig Johnson
    Novell Support Connection SysOp
    *** For a current patch list, tips, handy files and books on
    BorderManager, go to http://www.craigjconsulting.com ***

  • Appropiate way for sending an XML Structured file to the Queue

    Hi
    I am reading all my Database Table data and construcing an XML file .
    Now i want to send this XML file to the MQ (Queue ) as destination .
    Please tell me what will be the best approach in these two cases :
    1. Construct an XML file and store it in a drive (say with file name as Ravi.xml) and then pick that with the help of File API and send it as an attachment to the Queue
    (I dont whether this is possible also sending a attachment to the Queue )
    2.Use the ByteMessage /TextMessage Construct an XML file dynamically with the help of DOM API and post that Message to the Queue .
    Please help . I am still doing R&D on this .

    duplicate post. http://forums.sun.com/thread.jspa?messageID=10896758&#10896758

  • SAP MDM 5.5 System Copy

    Hello we receive from the business a request to do an refresh of our SAP MDM 5.5 QA system with the MDM 5.5 Production system.
    But I didnu2019t find any informationu2019s about this process on SAP MarketPlace neither in Googleu2026..
    Does anybody know what is the step for doing such a refresh ?
    Or where could I find info about this ?
    Many thanks in advance for your help.
    Dom./

    Hi  Dominique,
    You can create an Archive file to the repository from production environment and unarchive it into QA system.
    This will this repository will be exactly same as production.
    To create an Archive file follow following steps:
    1. Open MDM console and mount MDM Prod server. Right click on the repository and select "Create Archive".
    2. this will create a file with .a2a extn on MDM server Archive directory.
    To unarchive repository in QA follow below steps:
    1. Copy .a2a file of Prod repository from Prod MDM server archive directory and copy in QA MDM Server archive directory.
    2. mount QA MDM server in Console and right click and select Create Repository from Archive. This will open a popup window. specify DBMS details here and .a2a file of Prod repository.
    this way new QA repository will have exact same data and configurations from PROD repository. You can also over write an existing QA repository instead of creating a new repository using .a2a file of Prod repository.
    Hope this will help. Revert if  you have any question.
    BR,
    Shiv

Maybe you are looking for

  • Set up activities in PPM

    Hi all I have th e following recipe: operation 10 phase 20: set up phase phase 30: prod phase When transferring to apo the production version, it is created in APO the PPM. Everything is ok, but when I enter to modifiy something in the PPM and try to

  • Airport Extreme wireless no longer working. Need help!

    Until a couple of days ago, I had my brand new Airport Extreme (ver 7.2.1) connected to a cable modem and everything was ok. My Macbook and my Airport Extreme were going wireless fast and easy. After moving out of town, I've changed internet provider

  • Can't Copy Image Into Textedit

    This might be a coincidence but then maybe not... ever since I've installed MacOSX 8, I can no longer drag images or copy/paste images into TextEdit docs. Is there a TextEdit section here? Anyway, Logging in as a different user does not help. Trashin

  • Ovi sign in Issue on E5

    Hi all I have a major issue on usage of OVI store on my E5 , every time I enter my username & password it just gives me a POP UP " Invalid Username " .....but the same ID works on my PC.....Appreciate ur inputs on this

  • User in landscape

    hi expert i want know how to create new user in SAP Landscape.