How to change inner content of HTML tag using HTMLDocument?

I want to change the inner content of an HTML tag from a HTMLDocument. The tag is like
<span id ="id1">Replace me</span>.
So I want to change the text "Replace me" inside the span tag and replace it with an other text.
I can get the span element using
HTMLDocument.getElement("id1")
I have tried many things with the Element instance i got from getElement. But I find no way to change the inner content of the HTML element. Any ideas?

If I use JDK 1.5 the SPAN tag works, so I checked the core of the problem which is inserting HTML code in an HTML tag.
setInnerHTML works fine for block tags like DIV but not if the tag is a leaf element like the SPAN tag. I have tried to use the following code for leaf elements:
Element elem = m_htmlDocument.getElement(id);
int nStartOffest = elem.getStartOffset();
int nEndOffset = elem.getEndOffset();
int nLength = nEndOffset - nStartOffest;
m_htmlDocument.replace(nStartOffest, nLength, html, elem.getAttributes());
This works, but only if the new HTML string does not contain HTML tags like a link <href..... >. If the string contains HTML tags the replace method masks all characters like < or >. So the link is not shown as link in the HTML page but as HTML text.
The next thing I have tried is using
m_htmlDocument.setOuterHTML(elem, html);
This works too but it replaces the whole original HTML element like the SPAN tag.
So there is still the question how to insert HTML text into a leaf Element in a HTMLDocument.

Similar Messages

  • How to change the textarea to html editer in knowledge maintenance page ?

    Hi, experts,
    When we maintain the knowledge, we typed infomation into the textarea.
    Now we want to use html tags to show the knowledge info, so that the text can be shown in html table.
    how to change the textarea to  html editer ?
    Thanks.
    Oliver.

    closed.

  • How to change the color for HTML words in JEditorPane?

    Hi Sir,
    In the JTextPane , we could change the word's color by using:
    Style style = doc.addStyle("test",null);
    StyleConstants.setForeground(style, Color.red);
    doc.setCharacterAttributes(10,20,syle,true);
    we can change the text into red color,which range is from 10 to 30.
    But how to change the color for HTML words in JEditorPane?

    Hi,
    you can use an AttributeSet to apply the foreground color. Let's say, doc is a HTMLDocument, then SimpleAttributeSet set = new SimpleAttributeSet();
    doc.getStyleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, "#0D0D0D"); would apply a color to a given AttributeSet. The AttributeSet with your color then can be applied to a selected range of text in a JEditorPane by   /**
       * set the attributes for a given editor. If a range of
       * text is selected, the attributes are applied to the selection.
       * If nothing is selected, the input attributes of the given
       * editor are set thus applying the given attributes to future
       * inputs.
       * @param editor  the editor pane to apply the attributes to
       * @param a  the set of attributes to apply
      public void applyAttributes(JEditorPane editor, AttributeSet a) {
        ((HTMLDocument) editor.getDocument()).getStyleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, "#0D0D0D");
        editor.requestFocus();
        int start = editor.getSelectionStart();
        int end = editor.getSelectionEnd();
        if(end != start) {
          doc.setCharacterAttributes(start, end - start, a, false);
        else {
          MutableAttributeSet inputAttributes =
            ((SHTMLEditorKit) editor.getEditorKit()).getInputAttributes();
          inputAttributes.addAttributes(a);
      } Ulrich

  • How to change the "content created" date/time in FCPX?

    Since I've had problems importing my whole iMovie event library into FCPX I decided to run some tests with importing individual files (part of iMovie events and originally imported from camera into iMovie). Some of them for some reason got the wrong "content created" date/time in them while in iMovie they have the right date/time set. Does anybody have an idea on how to change the "content created" timestamp?

    I had a bunch of DV files that imported stamped with the file modification date and time.  I did not find a way to change it in FCPX. With FCPX not running, I used A Better Finder Attributes to modify the creation and modification dates of the files in the event folder. FCPX reconnected to them but the event still showed the old range of dates so I created a new event and moved the clips to it. Maybe ther is a beter way but that is how I did it.

  • How to change the Content-Transfer-Encoding for the fmddataa.fmd from base

    Dear all,
       When I using this SO_DOCUMENT_REPOSITORY_MANAGERto send email,I find the fmddata.fmd  file have been changed  to binary file attachment. I don't hope so.any one have good idea to avoid this case occur?
      Can you tell me how to change the Content-Transfer-Encoding for the fmddata.fmd from base64 to quoted-printable.  The quoted-printable is the Content-Transfer-Encoding for text file with extension .txt
    Best Regards,
    Merry

    Thank you

  • How to change table content ...

    Hi All,
    Pl. give us soltution for the following :
    1. How to change table content of standard table ?
        (eg. mara content not from MM02.).
    2. How to add field in standard table ?
    waiting reply.
    Yusuf

    Hi  Yusuf,
    Modifying a standard table through a program using SQL statements is highly risky. However if u wish to do it programatically and not through MM02, you have the option of using BAPIs.
    Goto transaction BAPI and through the application hirarchy, goto Material Management section. There i am sure u will find some BAPIs to modify material master and they are the most stable mode of update programatically.
    Hope this helps.
    Regards,
    Aditya

  • On opening up toast to burn its telling me that the tv standard is set to ntsc but all of my content is in pal format. how to change the content to ntsc seeing i am using final cut 10.

    on opening up toast to burn its telling me that the tv standard is set to ntsc but all of my content is in pal format. how to change the content to ntsc seeing i am using final cut 10.

    Select the Project in the Browser.  Go to the Info section of the Inspector.  Click the Modify Settings button.  For  Video Properties, change the Format from PAL to NTSC.  Export again, you'll be fine.

  • How to Change label content in a sequence ?

    OverView: I am using VS 2012 , WPF and C#.
    I have got 60 radio buttons in 20 groups. 3 radio button per group name(out of 60 radiobuttons, only 20 can be checked at a time).
    Radiobuttons are C, NC,NA in each groupname.
    I have 20 labels in other form which i intend to link with radiobuttons having name only NC. for example, Label_1 content will only change when NC is checked else it's by default empty. 
    Problem:
    I can change the content of the label using if and else. BUT problem is:
    For example:
    Label names are Label_1 to Label_20. I have arranged them in a line from Label_1 to Label_20. Every label is connected to NC radiobuttons. When user checks only three NC's then it just changes the content of the three labels which is good as per requirement
    but as each label is connected to a certain radiobutton, vacant ugly spaces are created which is not the requirement. 
    Question:
    I want to know is there any kind of loop or something that if only 5 radiobuttons are NC then the first five label content should change ? I know that i linked the labels with radiobuttons thats why they change. but there should be a way to generally change
    the content of the label. some loop or something. Plz help.
    Why i require all this:
    Basically, Nc means non-compliant. so at the end of the application, i want to give the user the list of all non-compliant factors.

    I'm not sure I understand exactly what you're doing here, but I have a somewhat different approach I think I would probably use.
    I'd make a usercontrol which I used for each question.
    Add 2 public dependency properties:
    Label text
    Selected option
    Arrange the label and 3 radio buttons in the usercontrol to suit the requirement - probably using a grid.
    As a radio button is checked/unchecked change the value of selected option DP.  As the DP changes, set the appropriate radio button.
    I could then new up one of these things, set the label and add it to an itemscontrol or listbox.
    ( I guess I'd also need some sort of spacer kind of control to group them maybe.)
    If I wanted to know which questions are a particular option I could just iterate the items and check the selected option dependency property. I could do that using linq.
    If I wanted to update some collection of data I could bind those properties or iterate again.
    Hope that helps.
    Technet articles: Uneventful MVVM;
    All my Technet Articles

  • Changing the src of include tag using selectonemenu with ajax

    tell me how to change the source of include tag so that it will show a new page as my select one menu changes..
    and also i don,t want to reload the whole page so i want to use Ajax in that so if anyone have some
    idea how to do it please post......

    Help me!

  • TS4268 how to change apple id on face time using macbook air

    how to change apple id on face time using macbook air

    coolguy1981 wrote:
    How can u format the hard drive since I am using the MBA. Formatting will delete also the recovery space and how to start with new installation? This is not going to work.
    No, that's not true. This is one of the 'benefits' of Lion (if you want to see it that way). The OS is on a separate partition and you can reinstall the OS without another physical drive.
    What you do is reboot the computer while holding down the 'option' key. From the list of disks that show up (you can release the 'option' key now), choose 'Recovery HD'.
    When you get to what looks like a Desktop, choose 'Reinstall OS X Lion'.  Shortly after this, you will get asked for your Apple ID. Put your own Apple ID in the box and everything should proceed smoothly from there.

  • Parse out the contents of meta tag using HTML.Tag

    I need help with using the HTML.Tag class. I don't even know where to start...
    I want to make a method that allows me to pass in a very long string and the NAME of the meta tag.. and will return the contents of the meta tag.. any help will be super..
    sorry i do not have much of a code base to start with.. I am just guessing on how to get this to work..
    private String getMetatag(String content,String Metaname)
    String Metacontents;
    Object HTML.Tag.META;
    Object HTML.Attribute.NAME.Metaname;
         Object HTML.Attribute.CONTENT;
    return Metacontents;
    }

    One of the way to get started is to check out how to overide (extend) the class
    HTMLEditorKit.ParserCallback.. Lets say the class is called class A
    Overide the methods for
    HandleSImpleTags( HTML.Tag t, AttributeSet attribute, int pos) { }
    roughly, the implemenation in that method is like this:
    HandleSImpleTags( HTML.Tag t, AttributeSet attribute, int pos) {
    if(t.equals(HTML.Tag.META) {
    /// your procedure, what to do when encounter META tag
    // String str = (String) attribute.getAttribute(HTML.Attribute.NAME);
    // System.out.println(str);
    You would still need to find some detail examples on how to use class A .
    Roughly it is,
    parser.parse(inputstream, an_instance of_class_A, true); // method in a outer class like a main class
    parser is a instatiation of from the method getParser. This method need to be overidden as well.

  • How to convert table content into html format?

    Hi,
    Experts,
    How to convert internal data into HTML format is there any function module or piece of code to download content into HTML.
    Thank u,
    Shabeer Ahmed.

    Then use this code....
    REPORT  ytest_table_html1.
    *        D A T A   D E C L A R A T I O N
    *-HTML Table
    DATA:
      t_html TYPE STANDARD TABLE OF w3html WITH HEADER LINE,
                                           " Html Table
    *- Declare Internal table and Fieldcatalog
      it_flight TYPE STANDARD TABLE OF sflight WITH HEADER LINE,
                                           " Flights Details
      it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
                                           " Fieldcatalog
    *-Variables
    DATA:
      v_lines TYPE i,
      v_field(40).
    *-Fieldsymbols
    FIELD-SYMBOLS: <fs> TYPE ANY.
    *        S T A R T - O F - S E L E C T I O N
    START-OF-SELECTION.
      SELECT *
        FROM sflight
        INTO TABLE it_flight
        UP TO 20 ROWS.
    *        E N D - O F - S E L E C T I O N
    END-OF-SELECTION.
    *-Fill the Column headings and Properties
    * Field catalog is used to populate the Headings and Values of
    * The table cells dynamically
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'SFLIGHT'
        CHANGING
          ct_fieldcat            = it_fcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2.
      DELETE it_fcat WHERE fieldname = 'MANDT'.
      t_html-line = '<html>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<thead>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<tr>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<td><h1>Flights Details</h1></td>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '</tr>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '</thead>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<table border = "1">'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<tr>'.
      APPEND t_html.
      CLEAR t_html.
    *-Populate HTML columns from Filedcatalog
      LOOP AT it_fcat.
        CONCATENATE '<th bgcolor = "green" fgcolor = "black">'
            it_fcat-scrtext_l
            '</th>' INTO t_html-line.
        APPEND t_html.
        CLEAR t_html.
      ENDLOOP.
      t_html-line = '</tr>'.
      APPEND t_html.
      CLEAR t_html.
      DESCRIBE TABLE it_fcat LINES v_lines.
    *-Populate HTML table from Internal table data
      LOOP AT it_flight.
        t_html-line = '<tr>'.
        APPEND t_html.
        CLEAR t_html.
    *-Populate entire row of HTML table Dynamically
    *-With the Help of Fieldcatalog.
        DO v_lines TIMES.
          READ TABLE it_fcat INDEX sy-index.
          CONCATENATE 'IT_FLIGHT-' it_fcat-fieldname INTO v_field.
          ASSIGN (v_field) TO <fs>.
          t_html-line = '<td>'.
          APPEND t_html.
          CLEAR t_html.
          t_html-line = <fs>.
          APPEND t_html.
          CLEAR t_html.
          t_html-line = '</td>'.
          APPEND t_html.
          CLEAR t_html.
          CLEAR v_field.
          UNASSIGN <fs>.
        ENDDO.
        t_html-line = '</tr>'.
        APPEND t_html.
        CLEAR t_html.
      ENDLOOP.
      t_html-line = '</table>'.
      APPEND t_html.
      CLEAR t_html.
    *-Download  the HTML into frontend
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = 'C:\Flights.htm'
        TABLES
          data_tab                = t_html
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    *-Display the HTML file
      CALL METHOD cl_gui_frontend_services=>execute
        EXPORTING
          document               = 'C:\Flights.htm'
          operation              = 'OPEN'
        EXCEPTIONS
          cntl_error             = 1
          error_no_gui           = 2
          bad_parameter          = 3
          file_not_found         = 4
          path_not_found         = 5
          file_extension_unknown = 6
          error_execute_failed   = 7
          synchronous_failed     = 8
          not_supported_by_gui   = 9
          OTHERS                 = 10.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    none of the above function modules r obsolete...

  • How to change the content of GTC (terms and conditions) for Partner

    Hi all,
         We are using R/3 version of ISA B2B site. while creating order thru Shopping Basket we have requirement that We need to provide GTC (General Terms and Condions) for the Partner (View GTC link ).  Right now some default text is displayed in that window (text text text ext text text text text text like that). we need to change this.
    where i can change this text and enter our own terms and conditions.
    Please help me to resolve this,
    thanks in advance
    siva kumar

    Hi Siva,
    the GTC is shown in the JSP b2c/order/terms_and_conditions.jsp. If you have a look at the file, you will find the following code:
    <isa:translate key="b2c.order.termsAndConds.txt.dmy"/>
    The translate tag will render the language dependant text for the resource key "b2c.order.termsAndConds.txt.dmy". To change the content that is shown you can change the resource text or create your own resource key in the corresponding resource file. The resource files are located in the src-folder of the web application DC.
    Best Regards,
    Peter Kraus
    SAP Web Channel Consultant
    http://www.leonardo-it.com

  • How to embed jnlp file into html page using object tag

    hi everyone,
    i have written one jnlp file like this.
    <?xml version="1.0" encoding="utf-8" ?>
    <!-- JNLP file for Demo applicaion -->
    <jnlp spec="1.0+" codebase="http://localhost:9080/base/" href="SampleExample.jnlp">
         <information>
              <title>Demo Application</title>
              <vendor> </vendor>
              <description>Sample Demo Application</description>
              <offline-allowed/>
         </information>
         <security/>
         <resources>
              <j2se version="1.3+" />
              <jar href="common.jar" main="true" download="eager" />
              <jar href="classes12.jar" download="eager" />
              <jar href="toplink.jar" download="eager"/>
              <package name="com.applet.*" part="applet" recursive="true"/>
         </resources>
         <applet-desc name="grid" main-class="com.applet.PriceGrid" width="1000" height="300"/>
    </jnlp>
    i am trying embed that jnlp file using object tag like
    <OBJECT
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="1000" HEIGHT="300" NAME="grid">     
    <PARAM NAME="jnlp" VALUE="http://localhost:9080/base/SampleExample.jnlp">
    </OBJECT>
    but i am not able to load the applet using Web Start.
    Can anyone please help me. This is very Urgent for me.
    Thanks & Regards,
    Shiva.

    thanks.
    i am giving my problem clearly. i have one applet. Previously i am loading the applet in my html page using object tag like this...
    <OBJECT
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="1000" HEIGHT="300" NAME="grid">
    <PARAM NAME="CODE" VALUE="com.adp.base.applet.PriceGrid.class" >
         <PARAM NAME="ARCHIVE" VALUE="common.jar,classes12.jar,toplink.jar" >
         <PARAM NAME="NAME" VALUE="grid" >
    <PARAM NAME="type" VALUE="application/x-java-applet">
    <PARAM NAME= "cache_option" VALUE ="no">
    </OBJECT>
    now what i need to do is
    i need load the applet only first time using web start and when ever the applet code changes in the server i need to reload the applet.
    for that i kept all the applet resources in .jnlp file.i want to cache all the resources which are in .jnlp file and applet must be displayed within a web page within a browser.
    Webstart always open a new application windows.
    I need to run an Applet embedded within a web page within a browser.
    Is there a way to still use Webstart?

  • How to Read a program with  HTML tags from SO10

    Hi All,
    I have a html program in Standard text (SO10).But when I am trying read the program content using FM:  READ_TEXT, the html tags <b> </p> etc are creating problem. 
    They are retrieved as <(><<)>b>.
    What should we do to get same/original text as in SO10?  Is there any other FM for that? Any other way to achieve this?
    Thanks & Regards,
    Vimalan Ram

    here is the code sample.
    after reading the text using READ_TEXT you have to use CONVERT_ITF_TO_ASCII to convert the contents.
    DATA: itf_tab TYPE STANDARD TABLE OF   tline ,
    wa_itf TYPE tline .
    DATA: c_datatab TYPE tdtab_c132 .
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
       client                        = sy-mandt
        id                            = 'ST'
        language                      = sy-langu
        name                          = 'Y_RAJA_HTML'
        object                        = 'TEXT'
    *   ARCHIVE_HANDLE                = 0
    *   LOCAL_CAT                     = ' '
    * IMPORTING
    *   HEADER                        = HEADER
      TABLES
        lines                         = itf_tab
    EXCEPTIONS
       id                            = 1
       language                      = 2
       name                          = 3
       not_found                     = 4
       object                        = 5
       reference_check               = 6
       wrong_access_to_archive       = 7
       OTHERS                        = 8
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
    EXPORTING
    *   CODEPAGE                = '0000'
    *   FORMATWIDTH             = 72
       language                = sy-langu
       tabletype               = 'ASC'
    *   TAB_SUBSTITUTE          = ' '
    *   LF_SUBSTITUTE           = ' '
    *   REPLACE_SYMBOLS         = 'X'
    *   REPLACE_SAPCHARS        = 'X'
    IMPORTING
    *   FORMATWIDTH_E           = FORMATWIDTH_E
    *   X_DATATAB               = X_DATATAB
       c_datatab               = c_datatab
    *   X_SIZE                  = X_SIZE
      TABLES
        itf_lines               = itf_tab
    EXCEPTIONS
       invalid_tabletype       = 1
       OTHERS                  = 2
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards
    Raja
    Message was edited by: Durairaj Athavan Raja

Maybe you are looking for