0 Replies Latest reply: Aug 30, 2010 5:13 AM by 807580 RSS

    Parsing XML using Stax (Element vs Text)

    807580
      Hello

      We were trying to use Stax parser (Stream reader) to parse an XML file.

      Please consider the following XML file:
      <xml>
      <MyElem>
      <Name>Foo1</Name>
      <Data>100</Data>
      </MyElem>
      <MyElem>
      <Name>Foo2</Name>
      <Data>200</Data>
      </MyElem>
      </xml>

      By using streaming API, I need to distinguish between 'MyElem' and 'Name' and 'Data'
      I mean, I need to get the data like Element = 2 (Because MyElem appeared twice) and Text = 4 (Because 'Name' x 2, and 'Data' x 2)

      How can I distinguish between element (which doesn't contain text) and text (Name, Data)
      When I say getText it is returning '\n\t' etc. for element also. Which confuses. Is there any way to suppress this.

      Thank you in anticipation.
      Best Regards,
      Babu