IXML - Reading a specific tag/specific attribute

Hi,
I'm trying to get out a specific tag ans specific attribute from an xml string.
I built my method based on BCCIIXMLT2 & BCCIIXMLT11 and Parsing XML file to Internal table., however it doesn't seem to work.
I already tried 2 approach, none of them worked
The loops are ended before the get_attributes method is called.
My code:
METHOD /eby/if_xml_output_writer~finish_element.
* Based on program BCCIIXMLT2 & BCCIIXMLT11
* \\ ======= iXML =======
  DATA:
    lr_ixml           TYPE REF TO if_ixml,
    lr_xml_doc        TYPE REF TO if_ixml_document,
    lr_node           TYPE REF TO if_ixml_node,
*    lr_iterator       TYPE REF TO if_ixml_inline_iterator,
    lr_iterator       TYPE REF TO if_ixml_node_iterator,
    lr_nodemap        TYPE REF TO if_ixml_named_node_map,
    lr_stream_factory TYPE REF TO if_ixml_stream_factory,
    lr_istream        TYPE REF TO if_ixml_istream,
    lr_parser         TYPE REF TO if_ixml_parser,
    lr_nnmap          TYPE REF TO if_ixml_named_node_map,
    lr_attr           TYPE REF TO if_ixml_node,
    lc_name           TYPE string,
    lc_value          TYPE string,
    lc_prefix         TYPE string,
    li_type           TYPE i,
    li_indent         TYPE i,
    li_index          TYPE i,
    li_count          TYPE i.
* // ======= iXML =======
*=======================================================================
  CLASS     cl_ixml          DEFINITION LOAD.
*=======================================================================
  CHECK i_parent IS INITIAL.
*-- Create the main factory
  lr_ixml = cl_ixml=>create( ).
*-- Create the initial document
  lr_xml_doc = lr_ixml->create_document( ).
*-- Create the stream factory
  lr_stream_factory = lr_ixml->create_stream_factory( ).
*-- Create a stream for the input (string)
  lr_istream = lr_stream_factory->create_istream_cstring( i_input ).
*-- Create the parser
lr_parser = lr_ixml->create_parser( stream_factory = lr_stream_factory
                                     istream        = lr_istream
                                     document       = lr_xml_doc ).
*-- We don't need the stream any more, so let's close it...
  lr_istream->close( ).
* 1st attempt
*  lr_node = lr_xml_doc.
*  lr_iterator = lr_node->create_inline_iterator( ).
*  li_type     = lr_iterator->get_type( ).
*  WHILE li_type NE 0.
*    li_indent = lr_iterator->get_height( ) * 2.
*    CASE li_type.
*      WHEN if_ixml_node=>co_node_element.
*        lr_nnmap = lr_iterator->get_attributes( ).
*        li_index = 0.
*        li_count  = lr_nnmap->get_length( ).
*        WHILE li_index < li_count.
*          lr_attr  = lr_nnmap->get_item( li_index ).
*          lc_name  = lr_attr->get_name( ).
*          lc_value = lr_attr->get_value( ).
*          li_index = li_index + 1.
*        ENDWHILE.
*    ENDCASE.
*    li_type = lr_iterator->advance( ).
*  ENDWHILE.
* 2nd attempt
  lr_node ?= lr_xml_doc.
* Create a node iterator
  lr_iterator = lr_node->create_iterator( ).
* Get current node
  lr_node = lr_iterator->get_next( ).
* Loop over all nodes
  WHILE NOT lr_node IS INITIAL.
    li_indent = lr_node->get_height( ) * 2.
    li_indent = li_indent + 20.
    CASE lr_node->get_type( ).
      WHEN if_ixml_node=>co_node_element.
*       Element node
        lc_name = lr_node->get_name( ).
        lr_nodemap = lr_node->get_attributes( ).
        IF NOT lr_nodemap IS INITIAL.
*         Attributes
          li_count = lr_nodemap->get_length( ).
          DO li_count TIMES.
            li_index  = sy-index - 1.
            lr_attr   = lr_nodemap->get_item( li_index ).
            lc_name   = lr_attr->get_name( ).
            lc_prefix = lr_attr->get_namespace_prefix( ).
            lc_value  = lr_attr->get_value( ).
          ENDDO.
        ENDIF.
      WHEN if_ixml_node=>co_node_text OR
           if_ixml_node=>co_node_cdata_section.
*       Text node
        lc_value = lr_node->get_value( ).
    ENDCASE.
*   Advance to next node
    lr_node = lr_iterator->get_next( ).
  ENDWHILE.
ENDMETHOD.
Any idea what could be wrong?
Thanks in advance,
Peter

Thanks!
Unfortunately my code should also work on 46C, so XLST is not an option. Anyway I used some code from SAPLink  and it works fine now.
*-- Create the main factory
  lr_ixml = cl_ixml=>create( ).
*-- Create the initial document
  lr_xml_doc = lr_ixml->create_document( ).
*-- Create the stream factory
  lr_stream_factory = lr_ixml->create_stream_factory( ).
*-- Create a stream for the input (string)
  lr_istream = lr_stream_factory->create_istream_cstring( i_input ).
*-- Create the parser
  lr_parser = lr_ixml->create_parser(
                      stream_factory = lr_stream_factory
                      istream        = lr_istream
                      document       = lr_xml_doc ).
*-- Parse the stream
  lr_parser->parse( ).
*-- We don't need the stream any more, so let's close it...
  CLEAR lr_istream.
* Find the tag
  lr_rootnode = lr_xml_doc->find_from_name( c_tag_structureddocument ).
  lr_attributelist = lr_rootnode->get_attributes( ).
  lr_nodeiterator  = lr_attributelist->create_iterator( ).
  lr_attributenode = lr_nodeiterator->get_next( ).
* Find the attribute
  WHILE lr_attributenode IS NOT INITIAL.
    lc_name = lr_attributenode->get_name( ).
    IF lc_name = c_attribute_id.
      lc_value = lr_attributenode->get_value( ).
      EXIT.
    ENDIF.
    lr_attributenode = lr_nodeiterator->get_next( ).
  ENDWHILE.
  mc_output = lc_value.

Similar Messages

  • Read Filename form Adapter-Specific Message Attributes in Java Mapping

    Hi,
    I have scenario File to Mail adapter. How can i read filename from Adapter-Specific Message Attributes
    in java mapping.
    Thank you and Best regards
    Fernand

    Hello Fernand,
    Are u using DOM or SAX parser?
    In any case just put the Dynamic config code in the execute function or the other option is to define it as a private functionand call it in the execute,My personal advice would be the former.
    Just put this code in ur java mapping
    As fellow sdn ers have mentioned there is no need of the container method,just initialise the set param method and use it in the dynamice config code as follows
    public class YourClass implements StreamTransformation
         private Map map;
    public void setParameter(Map param)
         map = param;
    public void execute(InputStream in, OutputStream out) throws StreamTransformationException
                   DynamicConfiguration conf =(DynamicConfiguration) map.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
                   DynamicConfigurationKey KEY_FILENAME =DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    // read value
    File = conf.get(KEY_FILENAME);
    Now just call File in the mapping program,
    Should help u out 
    Regards,
    Tauseef

  • Can't search for specific tag - Dreamweaver 8

    All of a sudden, I can no longer search for a specific tag in
    Dreamweaver 8 (Mac OS 10.4.6). It was working fine and I had just
    run a sitewide search, then boom! The attribute plus (+) and
    minus(-) signs appear over the text "Search:" right next to the
    dropdown box that says Specific Tag. It only happens in the tag
    search option.
    Clicking on the plus or minus does nothing, and when I try to
    run the search, I receive the error that one of my attribute fields
    is empty.
    I've tried a reinstall and restart, but that did nothing.
    Please help!! I NEED this function! Thanks.

    Shutdown DW and manually delete the Preferences file.
    I can't remember where to find the file on the Mac, so
    hopefully one of
    our Mac gurus can chime in here!
    Thanks,
    Randy
    > All of a sudden, I can no longer search for a specific
    tag in Dreamweaver 8
    > (Mac OS 10.4.6). It was working fine and I had just run
    a sitewide search, then
    > boom! The attribute plus (+) and minus(-) signs appear
    over the text "Search:"
    > right next to the dropdown box that says Specific Tag.
    It only happens in the
    > tag search option.
    >
    > Clicking on the plus or minus does nothing, and when I
    try to run the search,
    > I receive the error that one of my attribute fields is
    empty.
    >
    > I've tried a reinstall and restart, but that did
    nothing.

  • Pse 7 cannot find all photos with a specific tag

    I keep my photos in a series of 'nested' subfolders by year and by topic and I have found that PSE7 will only find the first photo with a specific tag, for instance searching for one of our dogs by tag name will find the first time we saved a photo of her. It will not find her in the subsequent 7 years of folders/photos.  It is v irritating and I thought that I could do this search previously. Help please.  Thanks.

    Thanks, but this didn't work; PSE still finds the first photo with the specific search tag.

  • Is there a site-wide title tag that I can edit or are the title tags specific to each individual page?

    Is there a site-wide title tag that I can edit or are the title tags specific to each individual page?  I'm working on my title tags for Destination West at http://xibuhaohua.com and as you can see, it is in Chinese here as 西部豪华 but it's English here at Destination West.  So, I'd like to know if I can edit each separately because I think they should be in different languages.

    You can set the title for each page in the Page Properties dialog.
    Note that on a master page, you can set a page title prefix or suffix if you'd like all your pages using that master to share a title prefix or suffix.

  • View photos with a specific tag only

    I am using Adobe Photoshop Elements 11. How do I view only photos with a SPECIFIC tag, without photos that do not have that tag, but is included in a STACK. It seems that once a photo is included in a stack it is shown even if it does not contain the specific tag that is filtered. I find this very frustrating and hope that somebody can help me.
    Thank you.

    Marung2013 wrote:
    Thank you for the reply.
    What I meant with "... how will I get access to the option to show only the best matches" was - would it be included in an upgrade of the program or what? Is Adobe aware of this and are they planning to fix it?
    Only Adobe knows...
    It's an old problem:
    http://www.johnrellis.com/psedbtool/photoshop-elements-faq.htm#_Searches_are_showing
    Because of this situation I cannot make use of stacks in my catalogue, because then the filtering option is useless.
    I don't know how you are using stacks, but for me it's a very rare problem. I would like it solved, but it does not bother me very often. The problem arises when the items in a stack don't have the same tags. That should not happen if you create stacks before assigning tags.
    I think it would help if you described your own way to use stacks to convince Adobe that an upgrade is necessary.

  • Dreamweaver Help: Code Coloring specific tags

    Hello everyone,
    I would like to set some custom Code Colors on HTML tags in DW to help me in recognizing those tags when I open a page in DW's Code View. I was able to find this BLOG post saying that it this is possible in DW by updating some DW preference files; source: http://blogs.adobe.com/dreamweaver/2009/02/code_coloring_specific_tags.html.. I am a non-technical person so I find it difficult to do the setup. The reason I want this is for me to easily find the text in Code View just by noticing the code color.
    E.g. I want this <span class="specialText"> to have a red code color in DW's Code View
    I hope there's someone who can guide me on how to accomplish this.
    Thanks

    Go to Edit > Preferences > Code Coloring > HTML > Edit Coloring Scheme.
    In DW, <span> tags have the same color scheme as <p> and <h > tags.  I'm not sure  if you can change that.
    As a workaround for quickly finding all span tags of a certain class, use Find (Ctrl+F), Specific Tag, Find All button.  See screenshot:
    Nancy O.
    Message was edited by: Nancy O.  Not Special tag; Specific tag.

  • XML Parsing, how to get a specific tag?

    Hello,
    I'm new to Flex, am trying to load some data from xml file using httpservice. all is right, but i dont know how to access to a specific tag.
    the xml mapping is showed in the  picture :
    i try to access Device1,  dataService.Lastresult.trames.tramdevices[???] somthing like that. sombody knows how to do? thanks a lot. I used xml with java but in flex is a little bit different. thank you for all.

    Hi neoto,
    Have you tried dataService.Lastresult.trames.tramdevices.Device1 ..??
    Thanks,
    Bhasker

  • Retrieve messages in PI trough a specific tag

    Hi all,
    how do I retrieve a message using a specific tag in a XML?
    I would like to retrieve all the xml's that has the tag .
    How can I do this?
    Regards,
    Sérgio Salomã

    You cannot search based on tags.
    It can be done when you have TREX engine engaged for index based searches.
    Refer this-
    http://help.sap.com/saphelp_nw70/helpdata/EN/43/60359ae92f5f87e10000000a1553f6/content.htm

  • Not able to see specific tags for FSCM Credit Management on BP master data screen

    Hi All,
    I have already set up Collections & Dispute Management,
    I am now on my way to start FSCM Credit Management setting up. I have already created the BP role (UKM000) and assigned it for direction customer to BP, but I am not able to see any specific tag on BP Master data related to Credit management, (just as I can see "Collections profile" tag, in reference to Coll. Mngmt).
    So, I am not able to see these tags yet: "Credit profile", "Credit worthiness", "Cresit limit and control".....under Credit Management BP role!
    What am I missing there? Have I got to activate BAdi UKM_R3_ACTIVATE in order to be able to "see" those BP tags???
    ....Or what else?
    I will reward with points if someone can provide me any hint about this issue.
    Thanks a lot.

    Hi Pallavi,
    Many thanks for your quick response. However, I have not succeeded in seeing that tab.
    Let me tell you, I may be confused by a document I downloaded from internet about the BP master data views (as for the FSCM Credit Management role, of course) . Please find below the commented tag. It is an imaged I copy to you from that document I told you, for you to see which tag I am talking about:
    I don´t know the content of that tab...but I would like to see it in place....you know..
    Now, I checked you last answer and I saw that everything was already set by factory, please find below:
    BUS4 view:
    BUS5 view:
    However, I´m still not able to see the tab I told you at the beginning (first image). Am I confused about something here? Many thanks for your patience (these things happens when you set FSCM Credit Management for the first time).
    Is that tag accesible?
    Many thanks!
    Wilson

  • How to write and read data in a specific memory location ??

    Hi Everyone:
    Does anyone know how to write and read data in a specific memory location by using Java ?
    I need pointers, but I don't know how to do it ??
    Thanks for answering
    Rodger

    Hi Everyone:
    Does anyone know how to write and read data in a
    specific memory location by using Java ?
    I need pointers, but I don't know how to do it ??
    Thanks for answering
    RodgerWith Java you cannot write to a specific memory location. Java does not have pointers. If you really want to do it, you need to use JNI, i.e write the required functions in C (or other languages that support pointers) and make those functions available to Java (through JNI). This approach is not portable. You can have a look at http://java.sun.com/docs/books/tutorial/native1.1/index.html
    Regards.

  • How can we read filenames from a specific folder

    Hi forum,
    I have a situation that, there are several files coming daily in a specific folder.
    I want to read filenames from that folder and want to get that filename in a variable.
    That filename contains account nos. which I need for further processing.
    Now, how can we read filenames from a specific folder with using Oracle PL/SQL Procedure?
    Please suggest.
    Thanks & regards,
    Kiran

    If you are on 10g (not sure which exact release I'm afraid) you might look at Chris Poole's XUTL_FINDFILES that lists the files in a directory using PL/SQL and DBMS_BACKUP_RESTORE.SEARCHFILES (all a bit undocumented as it seems to be provided as part of rman).
    The conventional (i.e. supported) approach is to use a Java stored procedure - there is an example on AskTom.
    Message was edited by:
    William Robertson

  • Use jsp tag output as another tag's attribute value

    I don't know anyone has ever tried this, one tag's attribute value needs to be dynamically set using another tag's output. Something like
    <layout:grid cols="<layout:write name="element" property="value"/>'' space='false'>
    </layout:grid>
    I want the cols attribute of grid tag to be the output of <layout:write name="element" property="value"/>
    The way I wrote is of course not working.
    But I know PHP can do things similar to this, JSP should be able to achieve something like this too.
    If anyone knows how to do this or using any alternative way to do this, please let me know.
    Shane

    something like this...
              OuterTag qParent = null;
              try {
                        Tag myParent = getParent();
                        while (myParent != null ) {
                          // loop up through tags until you find the one you want
                             if (myParent instanceof OuterTag) {
                                  qParent = (OuterTag) myParent;
                                  data = qParent.getSomeData();
                             } else {
                                  myParent = myParent.getParent();
                   }

  • Error - tag.getAsString : attribute 'title' not found in context ---- Help

    hi,
    I have included a jsp page in tiles definition xml. if i try to access an attribute defined in the tiles definition using tiles:getAsString method it is throwing the following exception
    Error - tag.getAsString : attribute 'title' not found in context
    can anyone help me how to get rid of this problem?
    Thanks in advance.

    yes ,
    reference already enter in web.xml
    <resource-ref>
              <description>
              </description>
              <res-ref-name>jdbc/iconnectDS</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              <res-sharing-scope>Shareable</res-sharing-scope>
         </resource-ref>
    still same problem
    pullareddy

  • p tags with attributes not removed from JTextPane

    We are using HTMLEditorKit with JtextPane to create a HTML Document Editor, for our project. [JDK 1.3.1.]
    When we have a simple <p> tag for paragraph in HTML and we start deleting things from end of the document, it works fine. But when we have a <P> tag with attributes like <p align='CENTER'> the delete key deletes the characters but the cursor remains in the line below and doesnot move up as the characters of above para get deleted. The HTML also retains the <p align='CENTER'> tag, which should have been removed. It seems its not able to identify <p> tags with attributes as Html para tags, and so not deleting it.
    How do we solve this without migrating to jdk1.4 ? Please help.

    Usually attributes such as 'align=center' are deleted along with a tag, regardless of whether it is a p tag or another one. But you would have to carefully test what exactly gets deleted because attributes are not only stored with paragraphs. They can exist for single characters and as well come from a style sheet.
    The best is to generate a dump of your document before and after deletion.
    You can use something like the below code (it is not optimized at all and thus could be implemented better but it works) to produce a dump
      public void listElements(Element elem, int indent) {
        int i;
        String is = getIndent(indent);
        String elemName = elem.getName();
        Document elemDoc = elem.getDocument();
        String cont = "";
        String theText = "";
        System.out.println(is + "--start-----");
        System.out.println(is + "Element Name:" + elemName);
        if(elemName.equals(new String("content"))) {
          try {
            theText = elemDoc.getText(
                    elem.getStartOffset(),
                    elem.getEndOffset() - elem.getStartOffset());
            System.out.println(is + "Content: " + theText);
            if(theText.indexOf("\r") > -1) {
              System.out.println(is + " plus \\r");
            if(theText.indexOf("\n") > -1) {
              System.out.println(is + " plus \\n");
          catch (Exception e) {
        listAttributes(elem, indent);
        if(!elem.isLeaf()) {
          for(i=0;i<elem.getElementCount();i++) {
            listElements(elem.getElement(i),indent+2);
        System.out.println(is + "---end----");
      public void listAttributes(Element elem, int indent) {
        Object key;
        String attr;
        String attrName;
        int pos;
        String is = getIndent(indent);
        AttributeSet as = elem.getAttributes();
        Enumeration an = as.getAttributeNames();
        try {
          while(an.hasMoreElements()) {
            key = an.nextElement();
            attrName = key.toString();
            attr = as.getAttribute(key).toString();
            System.out.println(is + "Attribute Name: " +
                      attrName + " Attribute Content: " + attr);
            if(attr.indexOf("\r") > -1) {
              System.out.println(is + " plus \\r");
            if(attr.indexOf("\n") > -1) {
              System.out.println(is + " plus \\n");
        catch (Exception e) {
          e.printStackTrace();
      }Hope that helps
    Ulrich

Maybe you are looking for

  • Preview images in Finder (default opened by Preview) gone

    Since a couple of days the preview of images default opened by Preview are gone. Preview of files/images that are default opened by other programs are still there. I tried one of the answers in the (unanswered) topics where it was suggested to delete

  • Status Pending in EM 10g

    Hi experts, I'm having a oracle 10g which runs in Linux 64 bit. When I log in to the EM console everytime it displays the following msg. Status Status Pending also it gievs the Last Known State link. when I go in to that the General information displ

  • Pre-order album via iPhone screws up iTunes navigation

    This is a very specific bug, so I'm not holding my breath for any fixes soon. But here it goes: I pre-ordered an album through the iPhone. Now, whenever I launch the iTunes App, it will momentarily open the correct page, and then suddenly jump over u

  • Retrieving the data

    i have submitted a form(designed in livecylce designer) with my details. how can i retrieve those details into a pdf form when i take that istance again. thanks in advance jayasree

  • HELP doesn't answer

    In every menu, as in the Finder, menu help at right; as in Mail, in Safari, when I click on "Help", nothing occurs. I have no more Help answering. My computer system is Mac OS X version 10.6.8 (Snow Leopard). Thanks for your help!