How to change the attributes of an XML file

hi peeps 'ope you can help me here i need to change the attributes of an xml file, i parse it first using a DOM parser but i cant find a way to change the attributes in the XML file, setAttribute() works only at runtime and doesn't change the attribute in the file itself. I can't find a method that will answer my question. I've searched through the forum and found similar threads....they say in order to write and change the attribute i must use the write() method of the XmlDocument class defined in com.sun.xml.tree.XmlDocument. But, i found another thread, and it says that com.sun.xml.tree.XmlDocument is not safe to use and i should use org.apache.crimson.tree.XmlDocument.....i can't find the XmlDocument class and the API for this package so i really dont know where to start...hope you guys can help me! thnx

thanks for responding roland....i already found the solution...i didn't use the XmlDocument class because i can't find any documents about it except for JAXP 1.0 here is my code snippet...i used the TransformerFactory and Transformer class to write
import org.w3c.dom.*;
import org.w3c.dom.traversal.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
Document doc = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
dbf.setValidating(false);
doc = db.parse(fileGetFile); //this is the XML file
n1 = (Node)doc.getDocumentElement();
e1 = (Element) n1;
NodeList nodeList = doc.getElementsByTagName ("File");
//just insert whatever you want to do with the XML...parse it..set/change the attribute..etc....sample snippet below changes the attribute downloaded to "no"
for(int iWriteFailed = 0; iWriteFailed <nodeList.getLength() ; iWriteFailed ++){     
n2 = nodeList.item(iWriteFailed);
e2 = (Element) n2;          
e2.setAttribute("downloaded", "no");}
try{
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.transform(new DOMSource(doc), new StreamResult ( new FileOutputStream ( fileGetFile) ) );}
catch(Exception trans){}
thanks for responding and keeping the information interchange alive here in the forum...
Pau

Similar Messages

  • How to change the output directory of .xml files

    Hi,
    There are lots of .xml files generated under
    $ORACLE_AS_HOME/j2ee/home/applications/xmlpserver/xmlpserver/xml.
    (ex:/usb/bipub3/oracle/oc4j_bi/j2ee/home/applications/xmlpserver/xmlpserver/xml).
    I found these files are generated in the following operation;
    1.Log in BI Publisher.
    2.Select the Schedules tab.
    I think they are kind of temp files so we will be able to delete them.
    But I'd like to know how to change the output directory.
    Can we change the above directory to other path?
    Regards.

    Why? As that may invalidate support since you configure/alter the deployment.
    The location is specified in oc4j_bi\j2ee\home\applications\xmlpserver\xmlpserver.war, so you could go into the war file and alter it.

  • How to change the date format in xml form?

    hi,
    How to change the date format in xml form?
    For example:  11/20/2008 3:00:03 PM    ->   11-20 03:00
    Any opinions greatly appreciated!
    Thanks.
    Edited by: ke wenxing on Dec 2, 2008 8:33 AM

    You could go to System - User Profile - Own Data would take you to the "maintain user profile screen"
    Click the defaults button and change the date format.This changes date format for all the dates in your login.

  • How to place the images in Indesign xml file by Javascript?

    How to place the images in Indesign xml file by Javascript?
    We got the Indesign xml file, how to give the image placement link by Indesign javascript? Please help me its urgent.

    Hi,
    You can pass the image url as a href attribute=> file:///Users/me/Documents/my_pic.jpg directly within your xml. It just needs that you pass a local, static and valid url.
    If you want to add image later once the xml is flowed and so target specific nodes and inject images, it's a bit more complex. If the node is not part of the layout, you may try to reach the XMLElement objet and such an attribute, then layout the element.
    var x = some XMLElement
    x.xmlAttributes.add("href","file:///Users/m/Documents/my_pic.jpg" );
    If already placed, then you have to get the associated pageItem, then place your file into it.
    pagItm.place ( File ( "/Users/m/Documents/my_pic.jpg" ) );
    Hope that helps,
    Loic
    http://www.loicaigon.com

  • I have 100 groups in planning for those 100 groups i want to build roles like interactive,view user,planner etc.for those how to change in export -import folder .xml file  in that edit  how  to change user roles in that xml it will generate automatic id.h

    I have 100 groups in planning for those 100 groups i want to build roles like interactive,view user,planner etc.for those how to change in export -import folder .xml file  in that edit  how  to change user roles in that xml it will generate automatic id.how to do that in xml file ?

    Thanks john for you are reply.
    I had tried what you sad.I open shared service in that foundation project i had export shared service.after that in import-export file.In that role.csv,user.csv,group.csv.Like this file have.When i open user file added some users after i trying save in excel it shown messgse
    I click yes and save the .csv file and import from share servie. i got error like this
    am i doing right way john.or explain clearly

  • How to change the attribute name for a relation

    When the Data Modeler engineers a logical model into a relational model it create table columns for the relations. The names of the generated columns are listed in the attributes list in the properties dialog of the relation. The actual name of the attribute gets calculated by the attribute name of the entity which is part of the relation. This is okay, if there is only one relation between two entities. But when there are two relations between two entities the second attribute gets a stupid number suffix. This makes it impossible to give the attribute a useful semantic meaning.
    When I engineer the model into a relational model I can change the column name in the relational model. Changing the column name in the relational model is not perfect but it would be okay for me, if it would not be overwritten during the next engineering run.
    So I have two questions:
    How can I change the attribute name in the attributes section of the properties dialog of a relation? See here for screen shot:
    http://public.ceving.de/2012050300/relationattribute.png
    And if it is not possible:
    How can I preserve any changes on column names in the relational model during a re-engineering run?
    Edited by: 931739 on 03.05.2012 08:07

    Hi,
    I've logged an Enhancement request on this.
    I don't believe it's possible to change it from the Entity or Relationship dialog, as it's not updatable in these dialogs.
    What you can do is change it in the Relational Model, and then reverse engineer the change back to the Logical Model.
    David

  • How to change the attribut of Form in Review Form in ISR

    Hi,
    We have to change the attributes of text fields of form ( e.g disabling the text field ) once user hits the Review Form button on MSS page
    Please let me know how to do it .
    Thanks
    Manish

    Hi Manish,
    You may write the Formcalc scripting for the respective field.
    //Check ISR control parameters for read/write access
    if($record.CONTROL_PARAM.ISR_MODE == "DISPLAY" |
       $record.CONTROL_PARAM.ISR_FORM_VIEW =="ISR_APPROVE" | <b>$record.CONTROL_PARAM.ISR_REVIEW == "true" )</b>
    then
         this.access = "readOnly"
    else
         this.access = ""
    endif
    Hope this helps.
    Thanks and Regards,
    Anto.

  • How to change the attributes of GUI CONTROLS in my own program.

    hi all,
    i just want to change the attributes of GUI CONTROLS in my own program.
    for example `
    How to set an ICON on my GUI BUTTON in the program?
    so what's the mapping between CONTROL in the SCREEN PAINTER and variable in the program?

    Hi Chao Liu,
    Ya , u first find out the PF-STATUS of the screen and goto that status and now u can modify the ICON u want .
    Finding the GUI status of the screen
    Goto that  TRANSACTION CODE or SCREEN
    On the Standard Menu bar Goto ( Menu path) System --> Status
    Now u get a pop-up System :status in that in SAP Data block u can find GUI Status. Now Double Click on that Status. It takes u to the Status of that screen.
    Now click on the Display --> Change Button on the application tool bar.
    If it is a standard GUI-status then it asks for the ACCESS KEY.
    if it is a custom defined GUI Status  then u can change the status .
    reward if helpful
    raam

  • How to change the  attribute of screen field to drop down list dynamically

    Hi All,
      Col X                   Col Y
      A                        input field
      B                       drop down list
    This is a tabular disply where the Screen field attribute for Col y  is NO DROP DOWN BOX.
    My requirement is to change the attribute of COl Y to DROP DOWN list depending on the value of
      COL X  dynamically.

    Dear Ajay,
    Actually this requirement is to enhance the standard screen for Tcode :EHSVU21.
    So depending on the 1st Column(Test no)  value ,i have to change the 3rd Column(Low.norm.result)
    property either to DROP Down or not.
    So in the PBO only the changes to be made and there is no field in SCREEN internal table for changing the attribute to DROP down. I checked SCREEN internal table where the field VALUE_HELP and REQUEST is useful but not  suitable for my case.
    Any solution available?

  • How to change the attributes of screen fields dynamically

    <b></b>
    well i have created a table by name empmaster_data with following fields.
    *emp_id.
    *emp_fname.
    *emp_lname
    *dob.
    *doj.
    *dept.
    *desig.
    now using a single screen i want to create,change and display the information.even i am using save and exit button.
    now i want to change the attributes of screen fields dynamically like active,input,output,invisible.

    Hi,
    Have Different Radio Buttons for the purposes what you have and use AT Selection Screen Output, Under the event Use loop at screen and with continue with your requirement.
    Hope This Info Helps YOU.
    <i>Reward Points If It Helps YOU.</i>
    Regards,
    Raghav

  • How to modify the priority of UWL XML File??

    Hello,
    How do you modify the priority of a UWL generated XML file? Ths xml file was generated when I registered the SRM system in UWL.
    I tried using the tab, Universal Worklist Configuration -> Upload new Configuration but it gives an exception "Operation not allowed".
    The reason for doing this,
    Conflicting ItemTypes are defined in the SRM XML file and one of the pre-defined SAP XML file (uwl_erp2005_buyer), and the SRM XML file has a priority of "Low" compared to medium priority for the erp xml. I need to change the SRM XML priority to "HIGH".
    Any help is appreciated.
    Thank you, John

    Erwin,
    Thanks for your reply.
    I downloaded the xml file, modifed some content. While uploading with the same name, making it a high priority and selecting the required system from the dropdown, "Adapt to System", it gives the following error
    Wed Apr 08 15:50:47 CDT 2009 : Operation not allowed on UWL generated Configuration:uwl.webflow.SAP_SRM_IAC
    Any reason the system does not allow doing this?
    John Miller

  • How to get the encoding of a XML file ...

    Hi,
    How do you get the encoding of a XML file?
    For example,
    <?xml version="1.0" encoding="SJIS"?>
    I am trying to retrieve the above encoding="SJIS", but I can't seem to locate the API for doing so.
    Thanks in advance for any help,
    Eric

    Hi ddossot,
    Thanks for your suggestion.
    However, the xerces.jar file that comes with my old tomcat server is an old version and thus, the getEncoding method is not even present in the DocumentImpl class. The option to update to a newer version of tomcat and xerces is not available. What a pity... :-(
    Well, I just have to try to find a way around. Worst case scenario, parse the first line in the xml file myself.
    Regards,
    Eric

  • How to change the artwork of a video file???

    is it possible to change the artwork of a video file. sometimes it comes up with its own artwork, and others there is just a black screen.... Thanks in advance

    Have you changed the artwork in a song? It is the same thing with a video. If you havent changed any artwork before then simply right click on the song/video and click on Get Info>then the Art Work tab

  • How to read the attribute of a XML element? Please help!

    Hi experts,
            <Batch>
                  <BatchCode ID= AA>
                    <DeliveryNote>190098</DeliveryNote>
                    <LotQuantity>1560</LotQuantity>
                  </BatchCode>
                  <BatchCode ID= BB>
                    <DeliveryNote>190098</DeliveryNote>
                    <LotQuantity>1560</LotQuantity>
                  </BatchCode>
              </Batch>
            Target message:
                <BatchDelivery>
                  <DeliveryNote>190098</DeliveryNote>
                  <DNQuantity>1560</LotQuantity>
                </BatchDelivery>
           From the source message I want to pull only those batch details where ID is BB.
           How to handle thsi in mapping?
    Thanks
    Gopal

    Hi Prabhu,
             I ma sorry I have two levels of checks in my source XML.
    <Batch>
    <BatchCode ID= AA>
    <BatchLabel>Primary</BatchLabel>
    <DeliveryNote>190098</DeliveryNote>
    <LotQuantity>1560</LotQuantity>
    </BatchCode>
    <BatchCode ID= BB>
    <BatchLabel>Secondary</BatchLabel>
    <DeliveryNote>190098</DeliveryNote>
    <LotQuantity>1560</LotQuantity>
    </BatchCode>
    <BatchCode ID= BB>
    <BatchLabel>Primary</BatchLabel>
    <DeliveryNote>190098</DeliveryNote>
    <LotQuantity>1560</LotQuantity>
    </BatchCode>
    </Batch>
    So I need to pull batch details where first the BatchCode ID= AA and then where BatchLabel value is 'Primary'
    Target message:
    <BatchDelivery>
    <DeliveryNote>190098</DeliveryNote>
    <DNQuantity>1560</LotQuantity>
    </BatchDelivery>
    How to do the graphical mapping for this situation?
    Thanks
    Gopal

  • How to change the HTTP Response as XML (Content Type "text\xml") ?

    Hi Friends ,
                     I have created one RFC Destination TYPE H . When i am trying to post some XML Message to that particular HTTP Service using POST method . It succesfully accepted the XML File but , it is returning the String as  " OK" . In the connection test trace i have seen the Content Type as "text/html" but *  I need to get as "text\xml" .* 
                     I need to get response back as XML not plain text . 
            1  Any Configuration setting  do we need to do on Service (SICF )  ?
             2. Or any other place we need to modify to get the HTTP Response as XML not plain text
                  Can you please help to solve the problem . Any clue ?
    Thanks & Regards.,
    V.Rangarajan
    Edited by: ranga rajan on Jan 2, 2008 2:07 PM

    Dear users,
    we have requirement sending SMS to the customers mobiles. I am successfully sending the messages to the customers mobiles by using the above method. Facing issues with response message. The response messages is in plain text fromat in single line like...Sent
    Using HTTP_AAE Receiver adapter.
    The response message was failed while excution of the message mapping with the error
    Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_MM_SMS_CUST_RES_; Details: com.sap.aii.utilxi.misc.api.BaseRuntimeException; Content is not allowed in prolog.
    please share the comments how to pass the Status of the message to SAP ECC from SAP HTTP adapter
    Regards,
    Sudir.

Maybe you are looking for

  • Runtime errors in BPM

    Hi all, We have a transformation step that is generating mapping errors at runtime. We do not see alerts generated by default on the alert framework for these errors. Is this expected? Should we be implementing the alert generation specifically insid

  • Start up problem Nokia 2520

    Hi, My 2 weeks old Nokia Lumia 2520 has a start up problem. When I switch on the phone I only see a blue screen with an unhappy smiley face :-( The battery is fully charged and I tried holding the 'power on'button for 10 seconds, but it doesn't work.

  • Transferring music from an iPod Nano gen 1

    I have oneof those Nanos that needs to be returned.  Anyone know how I can transfer my music from the Nano to my computer.  The music was downloaded from cd's loaded onto an old computer, which no longer works.  Anybody?

  • NEW IPOD VIDEO/ ITUNES ISSUES. HELP!!

    OK here is my problem. I recently recieved my IPOD Video. Attempted to sync with PC... everything ok. Then tried to sync w/ ITunes... Big problem apparently I need to format all my songs to a new AAC?? Not even sure what that means. Any suggestions?

  • Mail composing Error

    Hi all,        I am new to workflow. I am composed the mail content with  struc SOLISTI1.            T_OBJCONT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE, write the message line by line and append in to T_OBJCONT.and describe the space for the t_object