Menu

How to get the xml attributes?

Help
rfeng
2011-07-05
2013-04-25
  • rfeng

    rfeng - 2011-07-05

    <ListingsChannel  SourceId="873" Channel="4" ServiceType="Analog> <…..></ListingsChannel>
    i can get the elements with the KvmSerializable, but i can't get the attributes, such as SourceId, Channle.
    which api/function should i used?  thanks!

     
  • Manfred Moser

    Manfred Moser - 2011-07-05

    SoapObject has methods to access the attributes. It however seems to be broken and we added a fix in the ksoap2-android project for that.

     
  • rfeng

    rfeng - 2011-07-06

    ok, i will try it, thanks!

     
  • rfeng

    rfeng - 2011-07-06

    Hi mosabua,

    <ListingsChannel  SourceId="873" Channel="4" ServiceType="Analog> <Name>Hillcreste - Time Warner</Name></ListingsChannel>

    Thanks for your help, when i use the SoapObject to access the attributes, but i can't get the right elements, for example, the "Name" element which type is a string, because readSerializable api wouldn't call the obj.getPropertyInfo(testIndex, properties, info); so it can't get the rigth type and will go to the readUnknown module.

     
  • Manfred Moser

    Manfred Moser - 2011-07-06

    what version of ksoap2-android are you using now and how are you parsing the response?

     
  • rfeng

    rfeng - 2011-07-06

    i use the ksoap2-android-assembly-2.5.6-jar-with-dependencies.jar.  version is 2.5.6

     
  • rfeng

    rfeng - 2011-07-06

    if (!implicitTypes || !(obj instanceof SoapObject))
    {
        obj.getPropertyInfo(testIndex, properties, info);
        obj.setProperty(testIndex, read(parser, obj, testIndex, null, null, info));
    }
    else
    {
    ((SoapObject) obj).addProperty(parser.getName(), read(parser, obj, obj.getPropertyCount(), ((SoapObject) obj).getNamespace(), name, PropertyInfo.OBJECT_TYPE));

    }

    because i used the SoapObject, so it will go to the else section codes.

     

Log in to post a comment.