Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: How to read from "XML Input Stream (StAX)"?

  1. #1
    Join Date
    Jun 2016
    Posts
    181

    Default How to read from "XML Input Stream (StAX)"?

    I have flow:

    "Text file input" (each line = one xml file)-->"XML Input Stream (StAX)"-->"User Defined Java Class"-->"Text file output".

    XML is like:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Body>
    <Header>
    <OrderId>65345</OrderId>
    </Header>
    <Lines>
    <Line LineId="1">
    <Quantity>1.000</Quantity>
    <Price>16.10</Price>
    <UnitOfMeasure>pcs</UnitOfMeasure>
    </Lines>
    </soap:Body>

    In ""User Defined Java Class"" I want to read this strem with some simple code:

    if(element name = "Quantity"){
    quantity = element value;
    }

    How to do this? I studied all examples data-integration\samples\transformations\XML * but I uderstand nothing. None of those examples show how to parse XML in simple way.

    Anyone can share some example?

    Thanks a lot

  2. #2
    Join Date
    Dec 2016
    Posts
    7

    Default Sample xml data fetching

    Hi,

    Sample xml parsing in a simple way is attached, you can check.
    Attached Files Attached Files

  3. #3
    Join Date
    Jun 2016
    Posts
    181

    Default

    This is not the answer for my question. I need Java class example with XML Input Stream StAX.

  4. #4
    Join Date
    Dec 2016
    Posts
    7

    Default XML Input Stream StAX

    Quote Originally Posted by Gosforth View Post
    I need Java class example with XML Input Stream StAX.
    The attachment will give you basic idea of how to use both Java class with XML Input Stream StAX in an xml parsing.
    Attached Files Attached Files

  5. #5
    Join Date
    Jun 2016
    Posts
    181

    Default

    Thank you very much!
    Why do you use "Select values 1" and "Select values 1"? To limit no of fields that are passing to the next step?

  6. #6
    Join Date
    Dec 2016
    Posts
    7

    Default

    Quote Originally Posted by Gosforth View Post
    Thank you very much!
    Why do you use "Select values 1" and "Select values 1"? To limit no of fields that are passing to the next step?
    Yes, to limit the no of fields, and to preview the data.

  7. #7

    Default

    I had a similar issue in parsing a large XML document from a vendor, in that the other XML step couldn't load the document in memory without crashing.

    Here's an example transformation: parse_deviceatlas_xml.ktr

  8. #8
    Join Date
    Jun 2016
    Posts
    181

    Default

    Thanks. Can you attach example XML?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.