View then modify content of xml file.

I am new in Java world and my background is database admin. What I am trying to achieve here is write a small java scripts code which would open connections.xml allow user to update connection definition.
So here is what I do using java scripts, I load the connections.xml:
xmlDoc.load("connections.xml");
Then I disply the current conection def:
var x=xmlDoc.getElementsByTagName("StringRefAddr");
for (var i=0;i<x.length;i++)
document.write("<tr>");
document.write("<td>");
document.write(x.getElementsByTagName("Contents")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</table>");
But this only displays the content of connections.xml.
What is the code to allow user to actually modify what he or she is seeing displayed?
If java scripts is not the appropriate way to do this then please advise on how to do this the simplest way possible.
Please advise.
Thanks.
Bobby.

So you're reading in this XML document and extracting some bits to display to the user? And then when the user changes those bits and says OK you are going to write out a modified XML document?
Actually, never mind. Figure out what you are going to do and start doing it. Then when you run into a problem, post a specific question about that problem. It appears your question is actually "I don't know what I should do" and it isn't possible to answer that on a forum.

Similar Messages

  • How to read the contents of XML file from my java code

    All,
    I created an rtf report for one of my EBS reports. Now I want to email this report to several people. Using Tim's blog I implemented the email part. I am sending emails to myself based on the USERID logic.
    However I want to email to different people other then me. My email addresses are in the XML file.
    From the java program which sends the email, how can I read the fields from XML file. If any one has done this, Please point me to the right examples.
    Please let me know if there are any exmaples/BLOG's which explain how to do this(basically read the contents of XML file in the Java program).
    Thank You,
    Padma

    Ike,
    Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
    Please help me.
    Thank you for your posting.
    Padma.

  • Problem of modifying dp-providers.xml file

    did it must run "dpadmin list" command first before run "dpadmin modify" command on the modified dp-providers.xml file(or other xml files)?
    I run "dpadmin list" command first,then edit the xml file and run "dpadmin modify" command .now,the demo portal can't display conrrectly.why?
    Thans for your help

    set logging to message in the
    AMConfig.properties. Then take a look at the debug logs in /var/opt/SUNWam/debug/desktop.debug
    that should give you information on whats going on ..
    alternatively you can also paste the logs here ..

  • How to parse contents from XML file in Java

    Hi All,
    I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
    How to parse Contents of XML file??
    Thanks in advance,
    Rajendra.

    Hi All,
    I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
    How to parse Contents of XML file??
    Thanks in advance,
    Rajendra.

  • Dobuts in modifying an UWL XML file

    Hi Friends,
    We have a requirement in UWL for a custom task TS90000104; the user should get the user decision note once he clicks the work item in UWL, where in he can enter the rejection reasons while rejecting a leave request. For this we need to modify the XML file associated with the task, we need the set the value of the property name UserDecisionNote to true.I have the following doubts in that:
    Will there be an XML file associated with every custom task?, If so where we can find them, If not then will there be a common XML file which we need to copy and change the task id and the other property names and then upload it? Please clarify.

    Thanks for the reply sapient.  I had a bit of a difficult time getting the XML file set up correctly because between the SAP help, the UWL with SAP Netweaver Portal book and various online examples, I was getting conflicting information as to how to do it.  First of all, when the UWL initially loads, you apparently see the template defined in the XML file.  After the UWL refreshes, it pulls the information from the actual workitem/definition and it overrides some of the settings in the XML.  I have a decision step with 3 outcomes.  If I don't define all 3 steps in the XML, it doesn't work.  I want my replace and reject steps to have the note as mandatory while approve doesn't require it.  My first few attempts resulted in all 3 outcomes requiring a note to be attached.  It seems the order you use to define the actions matters and the optional outcome must be defined first.  Here's the XML that worked for me..hopefully it is helpful to someone else:
       <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE UWLConfiguration PUBLIC '-//SAP//UWL1.0//EN' 'uwl_configuration.dtd'
    <UWLConfiguration version="1.0">
       <ItemTypes>
         <!-- Check Expense Report (Trip) -->
         <ItemType name="uwl.task.webflow.decision.TS91000143.ECDCLNT020" connector="WebFlowConnector"
              defaultView="com.sap.pct.erp.mss.tra.view.TripCheckView"
              defaultAction="com.sap.pct.erp.mss.tra.action.DisplayExpenseForm">
           <ItemTypeCriteria externalType="TS91000143" connector="WebFlowConnector"/>
           <CustomAttributes>
            <CustomAttributeSource id="WEBFLOW_CONTAINER" objectIdHolder="externalId"
              objectType="WebflowContainer" cacheValidity="final">
               <Attribute name="TripNumber" displayName="Trip Number"/>
               <Attribute name="EmployeeNumber" displayName="Employee Number"/>
             </CustomAttributeSource>
           </CustomAttributes>
          <Actions>
           <Action reference="com.sap.pct.erp.mss.tra.action.DisplayExpenseForm"/>
            <Action name="launchSAPDetails" handler="SAPMiniAppLauncher">
             <Properties>
            <Property name="display_order_priority" value="uwlExcludeFromPreviewDetail"/><!-- Hide action->
               </Properties>
             </Action>
             <!--Action name="viewPreviewDetail" handler="SAPMiniAppLauncher">
               <Properties>
                 <Property name="display_order_priority" value="uwlExcludeFromPreviewDetail"/>
               </Properties>
             </Action-->
           <Action name="approved" groupAction="yes" handler="UserDecisionHandler"
             returnToDetailViewAllowed="yes" launchInNewWindow="no">
            <Properties>
             <Property name="decisionKey" value="3"/>
             <Property name="UserDecisionTitle" value="Approve"/> </Properties>
                 <Descriptions default="Approved"/> </Action>
           <Action name="rejected" groupAction="yes" handler="UserDecisionHandler"
             returnToDetailViewAllowed="yes" launchInNewWindow="no">
            <Properties>
              <Property name="UserDecisionNote" value="mandatory"/>
             <Property name="decisionKey" value="2"/> </Properties>
                 <Descriptions default="Rejected"/> </Action>
            <Action name="replaced" groupAction="yes" handler="UserDecisionHandler"
             returnToDetailViewAllowed="yes" launchInNewWindow="no">
            <Properties>
              <Property name="UserDecisionNote" value="mandatory"/>
             <Property name="decisionKey" value="1"/> </Properties>
                 <Descriptions default="Replaced"/> </Action>   
    </Actions>
         </ItemType>
       </ItemTypes>
    </UWLConfiguration>
    I used the decisionKey method to designate each outcome.  FM sap_wapi_decision_read works nicely to help you figure out the key number for each outcome.

  • How to modify an existing xml file from java code.

    Hi
    I have worked on creating a new xml file from java code using xmlbeans.But if i try to modify an already existing file using java code I am unable to get errorfree xmlfile.
    For example if xml file(studlist.xml) is as below:
    <?xml version="1.0" encoding="UTF-8"?>
    <StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
         <Student>
              <Name>ram</Name>
              <Age>27</Age>
         </Student>
    <Student>
              <Name>sham</Name>
              <Age>26</Age>
         </Student>
    </StudentList>
    Now suppose i have set name to victor using student.setName,
    and set age to 20 using setAge from javacode,
    the new xml file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
         <Student>
              <Name>ram</Name>
              <Age>27</Age>
         </Student>
    <Student>
              <Name>sham</Name>
              <Age>26</Age>
         </Student>
    </StudentList>
    <Student>
              <Name>victor</Name>
              <Age>20</Age>
         </Student>
    As observed this is not a valid xml file.But how can i modify without any errors?

    I know it's an old post, but I found this while doing a google search for something else, and don't like to leave it un-aswered
    Just in case anyone has a similar problem... In this case the new elements have been appended outside of the root element
    What you need to do is first get the root element and then append the new children to that, there are several ways of getting the root element, which depend on what you want to do with the elements you get back here's a simple (incomplete) way.
    // gets the root element of the specified file (code not shown)
    Element rootElement= new SAXReader().read(file).getRootElement();Then just append the new elements as below (this is non-generic code and would need to be modified for your situation)
    // write a new student element
    Element student = document.createElement("Student");  // creates the new student
    rootElement.appendChild(student); // ***appends it to the root element***
    Element name = document.createElement("Name"); // creates the name element
    name.appendChild(document.createTextNode("Fred")); // adds the name text to the name element
    student.appendChild(name); // appends the name to the student
    Element age= document.createElement("Age"); // creates the age element
    age.appendChild(document.createTextNode("26")); // adds the age text to the age element
    student.appendChild(age); // appends the name to the studentThen flush ya buffers or whatever and write the file
    Edited by: Dream-Scourge on Apr 23, 2008 11:10 AM

  • Dynamically building web content using XML file(s)

    Hello All!
    I was recently tasked with a project to design a monitoring web application for our "in-house" built web applications. There is a certain set of modules and parameters that we need to monitor: GSLB --> Web Tier --> App Tier --> Database.
    Almost all (80%) of our applications share the same parameters that need to be monitored, but there are about a hundred of them. So here is what I'm thinking of doing....
    1. Create an XML document for each application (An example layout is included at the end of this post) and save it in the Applications directory.
    2. Setup a Spring Framework project, and create code to dynamically go through the Applications directory and kick-off the monitoring logic for each <application/> item. Basically, the code will just traverse through all of the xml files (I might even create just 1 xml file with all of the <application/> items in it), read the "metadata" for each application, and start the backend processing, as well as display the data in a dynamically-generated web GUI (based on the XML structure and data).
    Again, most of our applications (80%) have the same modules/parameters, therefore adding an application would only require us adding another <application/> element to the already-existing xml document (or adding an additional XML document). The code would do the rest...In regards to the rest 20% of applications, I would create a customize XML document with additional metadata (the code, in that case, would be able to handle the additional metadata).
    So here are my questions:
    1. What do you think of the idea itself? I'm sure that I'm not the only one who's thought of this, so are there any best-practices in this regard?
    2. The reason I thought of using Spring is that it is XML-based (there are many reasons for me using Spring actually -- Security, ORM integration, etc), and it might facilitate my efforts. I'm thinking that even if reading through the Applications directory isn't such a good idea, I can somehow utilize Spring's dependency injection & AOS to create the appropriate solution. Have anybody tried this before and willing to share ideas, implementation approach, etc?
    3. Other than Spring, what might help me accomplish this task?
    4. Is this feasible (from a time and effort stand-point), or should I just do it the old-fashioned way?
    Thanks in advance!
    Vladimir
    I am including a sample (very rough-draft) XML file of what the input might look like:
         <applications>
              <application name="Remote Application">
                   <vip>somethingUNIQUE.mycompany.com</vip>
                   <sys-level>LAB</sys-level>
                   <lb-type>GTM</lb-type>
                   <farms>
                        <farm name="Farm 1" id="1">
                             <member-name>sslname.mycompany</member-name>
                             <ip-address>34.34.24.242</ip-address>
                             <application-servers>
                                  <application-server name="Some Name1">
                                       <ip-address>
                                            34.983.238.32
                                       </ip-address>
                                  </application-server>
                                  <application-server name="Some Name 2222">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </application-server>
                                  <application-server name="Some Name 3425">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </application-server>
                             </application-servers>
                             <web-servers>
                                  <web-server name="Some Name1">
                                       <ip-address>
                                            34.983.238.32
                                       </ip-address>
                                  </web-server>
                                  <web-server name="Some Name 2222">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </web-server>
                                  <web-server name="Some Name 3425">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </web-server>
                             </web-servers>
                        </farm>
                        <farm name="Farm 2" id="2">
                             <member-name>sslvpn01.downingtown</member-name>
                             <ip-address>34.34.24.250</ip-address>
                             <application-servers>
                                  <application-server name="Some Name 3425">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </application-server>
                             </application-servers>
                             <web-servers>
                                  <web-server name="Some Name1">
                                       <ip-address>
                                            34.983.238.32
                                       </ip-address>
                                  </web-server>
                                  <web-server name="Some Name 3425">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </web-server>
                             </web-servers>
                        </farm>
                   </farms>
              </application>
              <application name="Tech Tools">
                   <vip>technicalUNIQUE.tools.mycompany.com</vip>
                   <sys-level>LAB</sys-level>
                   <lb-type>GTM</lb-type>
                   <farms>
                        <farm name="Farm 1" id="1">
                             <member-name>tools.tech</member-name>
                             <ip-address>34.34.24.214</ip-address>
                             <application-servers>
                                  <application-server name="Some Name 2222">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </application-server>
                                  <application-server name="Some Name 3425">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </application-server>
                             </application-servers>
                             <web-servers>
                                  <web-server name="Some Name1">
                                       <ip-address>
                                            34.983.238.32
                                       </ip-address>
                                  </web-server>
                                  <web-server name="Some Name 2222">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </web-server>
                             </web-servers>
                        </farm>
                        <farm name="Farm 2" id="2">
                             <member-name>tools.tech222</member-name>
                             <ip-address>34.34.24.415</ip-address>
                             <application-servers>
                                  <application-server name="Some Name1">
                                       <ip-address>
                                            34.983.238.32
                                       </ip-address>
                                  </application-server>
                                  <application-server name="Some Name 2222">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </application-server>
                                  <application-server name="Some Name 3425">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </application-server>
                             </application-servers>
                             <web-servers>
                                  <web-server name="Some Name1">
                                       <ip-address>
                                            34.983.238.32
                                       </ip-address>
                                  </web-server>
                                  <web-server name="Some Name 2222">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </web-server>
                                  <web-server name="Some Name 3425">
                                       <ip-address>
                                            34.343.248.32
                                       </ip-address>
                                  </web-server>
                             </web-servers>
                        </farm>
                   </farms>
              </application>
         </applications>

    Hello jschell!
    Again, the question was more about the overall architecture and design rather than monitoring implementation.
    So here is what I have now:
    1. A spring application that will do the following:
    Read in the "architecture.xml" file (a portion is shown below). This file will dictate not only the type of monitoring but also the layout (explained later).
    The architecture.xml is marshalled to entity objects -- Model (s), with nested Model "children"
    This array of Model(s) is what the server-side application will use to populate the monitoring parameters.
    When the Impl gets a hold of the Model(s), it traverses through all of these entities and does whatever processing it needs to do (Health check, routing check, etc), and produces Item(s) objects, which are similar in structure to the Model(s) entities, but have actual values that need to be displayed on the front-end. Each item might have an array of other, children, Item(s)
    2. A GWT application asks for the Items array, and displays them on the front-end.
    What I did already:
    *1. Created a base Spring project that accepts GWT requests and returns a set of Item(s) (statically-generated, since I don't have the proper Impl yet).*
    *2. Created the GWT project and the layout. GWT communicates with the Spring app (which runs on tomcat for now) and upon retrieving the Item(s) it recursively renders them into displayable items, with different background, borders colors, width, etc (based on the populated values and their nested children, if any) . The last code snippet is the definition of the Item class.*
    Basically, the architecture is setup and the next step is the actual implementation of the monitoring and routing logic -- which wasn't the point of this post, since I already did most of it for a different project :)
    Thanks for the replies though....
    Vladimir
    <serviceView name="YYYYYYYY XXXX">
         <item layout="vertical">
              <!-- The top level application name -->
              <item name="Routing XXXXXXX  (RX)"/>
              <!-- The GSLB name and Active Farms printout -- Work in Progress-->
              <item  name="RX GSLB - xxxxxxx.xx.xxxxxxxx.com" layout="vertical">
                   <dynamicText type="gslb_farms">
                        <param name="vip" value="xxxxxxxx.xx.xxxxxxxxx.com"/>
                   </dynamicText>
              </item>
              <!-- The farms Row -->
              <item layout="horizontal">
                   <!-- The 1st Farm -->
                   <item name="Farm 1" layout="vertical">
                        <operationalState name="xxxxxxx.xx.yyyyyyy.com" type="gslb_farm">
                             <param name="vip" value="activate.g.comcast.com"/>
                             <param name="farmName" value="RX.WT.F1.VIP">
                        </operationalState>
                        <hc name="RX.WT.F1.VIP" type="poller"/>
                        <!-- DataCenter name -->
                        <item name="PDX" value="PDX"/>
                        <!-- Web Tier -->
                        <item layout="horizontal">     
                             <item name="WEB1" description="WEB1" detailedView="someservice_level_xmlname.xml">
                                  <hc name="RE.WT.F1.rdw01" type="poller"/>
                             </item>
                             <item  name="WEB2">
                                  <hc name="RE.WT.F1.rdw02" type="poller"/>
                             </item>
                        </item>
    public class Item implements Serializable{
         private static final long serialVersionUID = 1L;
         public final static String _ROUTING_STATUS_ENABLED = "_ROUTING_STATUS_ENABLED";
         public final static String _ROUTING_STATUS_DISABLED = "_ROUTING_STATUS_DISABLED";
         public final static String _ROUTING_STATUS_UNKNOWN = "_ROUTING_STATUS_UNKNOWN";
         public final static String _HEALTH_STATUS_GOOD = "_HEALTH_STATUS_GOOD";
         public final static String _HEALTH_STATUS_BAD = "_HEALTH_STATUS_BAD";
         public final static String _HEALTH_STATUS_UNKNOWN = "_HEALTH_STATUS_UNKNOWN";
         // This is what will be printed out -- the static text
         private String name = null;
         // If detailedView is not empty, then a link for this item shows up
         // that opens up a Dialogue Box
         private String detailedView = null;
         // If detailedView is not empty, then a link for this item shows up
         // that opens up a completely new Service View
         private String serviceView = null;
         // Layout Information
         private boolean verticalLayout = true; // VERTICAL or HORIZONTAL
         // Coloring Information
         private String routingStatus = _ROUTING_STATUS_UNKNOWN; // ENABLED, DISABLED, UNKNOWN
         private String healthStatus = _HEALTH_STATUS_UNKNOWN; // HEALTHY or NOT-HEALTHY
         // Children
         private Item children[] = null;

  • Dbms_xmlgen: write emp content to xml file

    Hi.
    I have the following procedure to write the content of the emp table in xml to a file:
    CREATE OR REPLACE PROCEDURE BSP_DBMSXMLGEN IS
    v_ctx DBMS_XMLGen.ctxHandle;
    v_file Utl_File.File_Type;
    v_xml CLOB;
    v_more BOOLEAN := TRUE;
    l_exception varchar2(2000);
    BEGIN
    -- XML context erzeugen
    v_ctx := DBMS_XMLGen.newContext('SELECT * from emp_big');
    -- Root Element und Zeilentag setzen
    DBMS_XMLGen.setRowsetTag(v_ctx, 'Emp');
    DBMS_XMLGen.setRowTag(v_ctx, 'Zeile');
    -- XML Dokument erzeugen
    v_xml := DBMS_XMLGen.GetXML(v_ctx);
    DBMS_XMLGen.closeContext(v_ctx);
    -- Ausgabedatei erzeugen
    v_file := Utl_File.FOpen('XML_DIR', 'BSP_DBMSXMLGEN.xml', 'w');
    -- In Datei schreiben
    WHILE v_more LOOP
    Utl_File.Put(v_file, Substr(v_xml, 1, 32767));
    IF Length(v_xml) > 32767 THEN
    v_xml := Substr(v_xml, 32768);
    ELSE
    v_more := FALSE;
    END IF;
    END LOOP;
    Utl_File.FClose(v_file);
    EXCEPTION
    when OTHERS then
    l_exception := sqlerrm;
    dbms_output.put_line('Error: ' || l_exception);
    END;
    The procedure works well with 14 emp rows. But after duplicating the rows a few times the procedure stops working...
    insert into emp_big select * from emp_big;
    commit;
    select count(*) from emp_big;
    COUNT(*)
    960
    exec bsp_dbmsxmlgen;
    The file content:
    <?xml version="1.0"?>
    <Emp>
    <Zeile>
    <EMPNO>7369</EMPNO>
    <ENAME>SMITH</ENAME>
    <JOB>CLERK</JOB>
    <MGR>7902</MGR>
    <HIREDATE>17.12.80</HIREDATE>
    <SAL>800</SAL>
    <DEPTNO>20</DEPTNO>
    </Zeile>
    <Zeile>
    <EMPNO>7499</EMPNO>
    <E
    The procedure stops writing to file in the middle of a table row...
    Any ideas?
    Thanks
    Markus

    Thanks, Marco, but I think I need to be more clear. The original XML data in the XMLType field looks like:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <metadata>
    </metadata>where "metadata" is the root node of the entire file. What happens is when I run the script listed above, the name of the field being queried gets added as a root node, which I don't want. I did figure out how to omit the "ROW" and ROWSET" nodes from being placed in the resulting XML flat file. Using the same script, I replaced:
    -- Root Element und Zeilentag setzen
    DBMS_XMLGen.setRowsetTag( v_ctx, 'Emp' );
    DBMS_XMLGen.setRowTag( v_ctx, 'Zeile' );with
    -- Root Elements
    DBMS_XMLGen.setRowsetTag( v_ctx, '' );
    DBMS_XMLGen.setRowTag( v_ctx, '' );I simply removed "Emp" and "Zeile." By doing this, those nodes are omitted. I still can't figure out how to omit the "XML_DATA" node.

  • How to export table contents in xml file format through SQL queries

    hi,
    i need to export the table data in to xml file format. i got it through the GUI what they given.
    i'm using Oracle 10g XE.
    but i need to send the table name from Java programs. so, how to call the export commands from programming languages through. is there any sql commands to export the table contents in xml format.
    and one more problem is i created each transaction in two tables. for example if we have a transaction 'sales' , that will be saved in db as
    sales1 table and sales2 table. here i maintained and ID field in sales1 as PK. and id as FK in sales2.
    i get the combined data with this query,
    select * from sales1 s1, sales2 s2 where s1.id=s2.id order by s1.id;
    it given all the records, but i'm getting two ID fields (one from each table). how to avoid this. here i dont know how many fields will be there in each table. that will be known at runtime only.
    the static information is sales1 have one ID field with PK and sales2 will have one ID filed with FK.
    i need ur valuable suggestions.
    regards
    pavan.

    You can use DBMS_XMLGEN.getXML('your Query') for generating data in tables to XML format and you can use DBMS_XMLGEN.SETROWSETTAG to change the parent element name other wise it will give rowset as well as DBMS_XMLGEN.SETROWTAG for row name.
    Check this otherwise XMLELEMENT and XMLFOREST function are also there to convert data in XML format.

  • Place contents of xml file to 2D array

    i have a xml file like
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE map SYSTEM "map.dtd">
    <map width="5" height="5" goal="6" name="Hallways of Dooom">
         <random-item type='lantern' amount='5' />
         <random-item type='health' amount='10' />
         <tile x="1" y="0" type="floor">
              <renderhint>floor:wood</renderhint>
         </tile>
         <tile x="0" y="1" type="wall" />
         <tile x="1" y="1" type="floor" startlocation="1" />
         <tile x="3" y="1" type="floor">
              <item type="treasure">Bar of Silver</item>
              <renderhint>floor:stone,blood</renderhint>
         </tile>
    </map>i was asked to creat a 5*5 2D array from it. each tile represents a position on the point. If the type of tile is wall, it is represented by number 2; if it is floor, it is represented by number 1.
    i have written my code as following:
    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.*;
    public class parsexml
        public void parseXML()
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         factory.setValidating(true);
         factory.setIgnoringElementContentWhitespace(true);
         try {
             DocumentBuilder parser = factory.newDocumentBuilder();
             Document doc = parser.parse(new File("hallways.xml"));
             System.out.println("XML file parsed.");
             processTree(doc);
         } catch (ParserConfigurationException e) {
             e.printStackTrace();
         } catch (SAXException e) {
             e.printStackTrace();
         } catch (IOException e) {
             e.printStackTrace();
        public void processTree(Document doc)
         int column = 0;
         int row = 0;
         int hori = 0;
         int vert = 0;
         String Type = "";
         Node element = doc.getDocumentElement();
         NamedNodeMap attrs = element.getAttributes();
         for (int i = 0; i < attrs.getLength(); i++) {
             Node attr = attrs.item(i);
             String attrName = attr.getNodeName();
             if (attrName == "width") {
              column = Integer.parseInt(attr.getNodeValue());
             if (attrName == "height") {
              row = Integer.parseInt(attr.getNodeValue());
         int[][] map = new int[row][column];
         NodeList children = element.getChildNodes();
         for (int i = 0; i < children.getLength(); i++) {
             Node child = children.item(i);
             String nodeName = child.getNodeName();
             if (nodeName == "tile") {
              NamedNodeMap attributes = child.getAttributes();
              for (int a = 0; a < attributes.getLength(); a++) {
                  Node attribute = attributes.item(a);
                  String attributeName = attribute.getNodeName();
                  if (attributeName == "x") {
                   hori = Integer.parseInt(attribute.getNodeValue());
                  if (attributeName == "y") {
                   vert = Integer.parseInt(attribute.getNodeValue());
                  if (attributeName == "type") {
                   Type = attribute.getNodeValue();
             if (Type == "floor") {
              map[hori][vert] = 1;
             } else if (Type == "wall") {
              map[hori][vert] = 2;
         print(map);
        public void print(int[][] map)
         for (int r = 0; r < map.length; r++) {
             for (int c = 0; c < map[r].length; c++) {
              System.out.print(map[r][c]);
             System.out.println();
        public static void main(String[] args)
         parsexml xml = new parsexml();
         xml.parseXML();
    }When i run the program, i found it doesn't fills the spcified position on the array. all I get is a 5*5 grid of 0s.
    Can anyone tells me why? thank you in advance.

    Unless someone is willing to put in the time to do your job for you, you'll have to debug it yourself. Put in some debugging statements. In their simplest form this is just a bunch of System.out.println("your message here") calls where you put in messages describing the current point of execution (like what method you just started or are about to finish) and the values of relevant data (such as method parameters, loop indices, whatever you feel is important).
    Then run the program and see what it tells you.

  • After downloading firefox I lost toolbars and menu bar, I can't hit view then toolbar's because the file,edit,view ect..bar is not there? Help

    I down loaded firefox 3.6 and now I can't see any of my tool bar's or menu bar. Usually I can click on view then toolbars and check the ones I want to see. But the tool bar with file, edit, view, tool, ect.. is not visible. I have gone in and checked on my start up which show they are suppose to be there and locked on top. But they are not there. If I open Internet Explorer they are all there. Whats up.

    Hit the '''Alt''' key to show the Menu bar, then open View > Toolbars and select Menu bar, so it has a check-mark. <br />
    https://support.mozilla.com/en-US/kb/Menu%20bar%20is%20missing

  • Importing content of XML file to table(s)

    I am looking for a way to import updates passed via XML file to a three tables.
    In IBM Domino it was facilitated while using DOMParser class.
    Does JDeveloper have a class or method for updating tables from XML file?

    To import a XML document to a dataabse table:
    1. Add <Oracle10g>/jdbc/lib/ojdbc14.jar, <Oracle10g>/jdbc/lib/servlet.jar, <XDK>/lib/xmlparserv2.jar, <XDK>/lib/xdb.jar and classes12dms.jar to Classpath.
    2. Create a table in Oracle database 10g, which includes columns for each of the element tags in the XML document.
    3. Create a connection with the database.
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn =
    DriverManager.getConnection("jdbc:oracle:thin:@<host>:<port>:<SID>",
    "<user>","<password>");
    4. Create a OracleXMLSave class object.
    OracleXMLSave oracleXMLSave =new OracleXMLSave(conn, "<table>");
    “<table>” is the database table.
    5. Set the tag for the row enclosing element.
    oracleXMLSave.setRowTag("<row-tag>");
    Each <row-tag> tag in the example XML document corresponds to a database column.
    6. Import the XML document to database:
    oracleXMLSave.insertXML(oracleXMLSave.getURL("file://c:/input.xml"));
    7. If the XML document has attributes apply an XSLT to convert the attributes to elements.

  • How do I modify invoice request xml file by adding posting date?

    Hi,
    We import customer invoice requests via xml files from an external data source. Currently the standard SAP xml file does not include the posting date, and invoices enter SAP with a blank posting date. When the invoice is released, the posting date is taken from the invoice date.
    Due to our month end processes, we have hundreds of invoice requests every month where we do not want posting date to equal the invoice date, and for each of those invoices the posting date is manually entered one invoice at a time during the release process. This is very time consuming.
    We would like to build functionality in our external system to create the posting date at the xml file generation stage. Could anyone let us know the following:
    - what is the name of the posting date field on invoice requests (invoice documents)?
    - where would we place the additional script in the xml file?
    I'm attaching one of our current xml files (which already contains one section that has been customized)
    Your suggestions would be appreciated.
    Thanks,
    Kerstin

    Kerstin,
    The closest i could find in the WSDL of the Manage Invoice Request Web Service that handles this integration is "<ProposedInvoiceDate>" or possibly even "<ProposedDeviatingPostingdate>", both of which sit directly under the <CustomerInvoiceRequest> element.
    For more information, go to the Service Explorer, find the ManageInvoiceRequestsIn Web Service, download the WSDL, and open it in SOAP-UI or something similar. This way you can see all the fields that you can write to, which is where i found these two elements.

  • Read rtf contents from xml file and print them in pdf using documaker

    I am using Documaker 11.2.
    Input file is XML and for a particular tag, rtf contents is passed like
    {\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial Narrow;}} \viewkind4\uc1\pard\b\f0\fs20 My\b0 name is Schoo.....
    I want to read this data excluding the RTF abstract and print the text alone in pdf along with format like paragraph,bold....
    The output file generated is PDF.
    Kindly let me know how can i achieve this in Documaker.

    There is no direct support for importing RTF from an XML extract. Perhaps feature 1514 "Mapping formatted XML data into multiline field" will be of some use. This was released in 11.0, I believe.
    Essentially you can establish paragraph and certain text formatting like bold and underline when you include the proper token information in the data. I believe this is similar to simple HTML tokens.
    Example: &lt;FIELD>&lt;P>First paragraph of data.&lt;/P>&lt;P>New paragraph with &lt;B>&lt;U>bold and underline text&lt;/U>&lt;/B>. Rest of paragraph normal.&lt;/P>&lt;/FIELD>
    The result is something like this:
    <P>First paragraph of data.</P><P>New paragraph with <B><U>bold and underline text</U></B>. Rest of paragraph normal.</P>

  • Modify contents of .htm file

    I have a .htm file that contains hundreds of links. If I hover the mouse over each link I can see the contents of that link. I want to change a constant in each for these links from "aaa" to "bbb". Is there a way to do this? What tool would I use to perform this? Thanks, Mark

    Note: This thread was originally posted in the [Conventional & Interruptable IO|http://forums.sun.com/forum.jspa?forumID=535] forum, but moved to this forum for closer topic alignment.

Maybe you are looking for

  • Can't trust this computer for iphone and ipad with Itunes

    hi all after updating to ios 7.1.1 on both my iphone 4s and ipad I keep getting this message when I connect my phone or ipad to my iMac :iTunes could not connect to this iPad. You do not have permission. then this : Do you want to allow this computer

  • Reconciliation account

    Hi gurus, user wants to eliminate the reconciliation acccount Asset in Control data of GL Master. He wants to post directly to that GL account so that he is asking to eliminate the reconciliation account from the GL master. What will be the impact on

  • Outlook syncclient stopped responding - again!

    Hi Everyone, Here we go again... I have a 3GS and all was working perfectly. I was able to sync my calendar great via the usb but then I upgraded to the new iTunes 9.0.3 and the iPhone OS 3.1.3. The dreaded "Outlook Syncclient has stopped responding"

  • Poor broadband

    Hi, Our broadband has been very poor for a long time now, yesterday it would connect at all so want to do something about it. On average, the line will drop connection 20 times a day, on some occassions that is per hour. The line has never been quick

  • Music in iCloud is grayed out

    I successfully logged into my music on iCloud from my work windows computer. THe second time I went to listen, all the tunes are grayed out. How to get them a second time?