Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    selectNodes problem

    Hello!

    Can anybody help me with XMLTools.selectNodes? This method return Object type, but in javadoc writes that this must be a list of nodes.How can I cast to array or convert to some List to iterate elements? I would be glad any sample.

    Thanks in advance...

    #2
    What are you doing? Why are you using XMLTools?

    Comment


      #3
      For example:

      Code:
      Object list=XMLTools.selectNodes(xmlData,"/response/item");
      each item have attributes, I need to put not empty values to another array. XML looks like this:

      Code:
      <response>
      <item object="Some.Idenifier.1">
      ...
      Item fields here...
      ...
      </item>
      </response>
      It would be perfect if I could arrange with Object as NodeList or Element[], but any convertations was not successful.

      Comment


        #4
        This worked for me:


        import com.google.gwt.core.client.JavaScriptObject;
        import com.google.gwt.core.client.JsArray;
        import com.google.gwt.user.client.Element;
        import com.smartgwt.client.data.XMLTools;

        JsArray<Element> statusElements = ((JavaScriptObject)XMLTools.selectNodes(xmlResponse,"/response/status")).cast();
        for(int i = 0; i < statusElements.length(); i++) {
        Element statusE = statusElements.get(i);
        String statusType = statusE.getAttribute("type");
        String statusMessage = statusE.getAttribute("message");
        status(statusType + " : ",statusMessage);
        }

        Comment

        Working...
        X