Faster way to read XML files using power shell !!

At the moment i have about 1000 XML files (ranging from size 15kb to 120kb), I have a powershell script which extracts information and writes all extracts to the same LOG file!!
It works well but am only concerned with the time it takes!! it took about 1.5 hrs to finish the script! Is this normal?
How can i speed it up, your inputs and thoughts helps!!
Reading XML using the following syntax!
$Inputfile=[xml](Get-Content $XFILE)
Script has only foreach loop!  and no other conditions.
cheers!

For a small file it is about twice as fast.  It gets faster as the file size gets bigger.
PS C:\scripts> Measure-Command {$xml=[xml](cat FooProx.xml -raw)}
Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 275
Ticks : 2758195
TotalDays : 3.19235532407407E-06
TotalHours : 7.66165277777778E-05
TotalMinutes : 0.00459699166666667
TotalSeconds : 0.2758195
TotalMilliseconds : 275.8195
PS C:\scripts> Measure-Command {$xml.Load("$pwd\FooProx.xml")}
Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 108
Ticks : 1081647
TotalDays : 1.25190625E-06
TotalHours : 3.004575E-05
TotalMinutes : 0.001802745
TotalSeconds : 0.1081647
TotalMilliseconds : 108.1647
¯\_(ツ)_/¯

Similar Messages

  • Reading XML file using BAPI and then uploading that xml file data into SAP

    I am getting a xml file from Java server. I need to take
    data from this file using BAPI and need to upload into SAP using SAP.
    Please tell me how to read XML files using BAPI's.

    <b>SDIXML_DATA_TO_DOM</b> Convert SAP data (elementary/structured/table types) into DOM (XML
    <b>SDIXML_DOM_TO_XML</b>  Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
    <b>SDIXML_DOM_TO_SCREEN</b> Display DOM (XML)
    <b>SDIXML_DOM_TO_DATA</b>
    data: it_table like t001 occurs 0.
    data: l_dom      TYPE REF TO IF_IXML_ELEMENT,
          m_document TYPE REF TO IF_IXML_DOCUMENT,
          g_ixml     TYPE REF TO IF_IXML,
          w_string   TYPE XSTRING,
          w_size     TYPE I,
          w_result   TYPE I,
          w_line     TYPE STRING,
          it_xml     TYPE DCXMLLINES,
          s_xml      like line of it_xml,
          w_rc       like sy-subrc.
    start-of-selection.
      select * from t001 into table it_table.
    end-of-selection.
    initialize iXML-Framework          ****
      write: / 'initialiazing iXML:'.
      class cl_ixml definition load.
      g_ixml = cl_ixml=>create( ).
      check not g_ixml is initial.
      write: 'ok'.
    create DOM from SAP data           ****
      write: / 'creating iXML doc:'.
      m_document = g_ixml->create_document( ).
      check not m_document is initial.
      write: 'ok'.
      write: / 'converting DATA TO DOM 1:'.
      CALL FUNCTION 'SDIXML_DATA_TO_DOM'
        EXPORTING
          NAME               = 'IT_TABLE'
          DATAOBJECT         = it_table[]
        IMPORTING
          DATA_AS_DOM        = l_dom
        CHANGING
          DOCUMENT           = m_document
        EXCEPTIONS
          ILLEGAL_NAME       = 1
          OTHERS             = 2.
      if sy-subrc = 0.  write  'ok'.
      else.             write: 'Err =', sy-subrc.
      endif.
      check not l_dom is initial.
      write: / 'appending DOM to iXML doc:'.
      w_rc = m_document->append_child( new_child = l_dom ).
      if w_rc is initial.  write  'ok'.
      else.                write: 'Err =', w_rc.
      endif.
    visualize iXML (DOM)               ****
      write: / 'displaying DOM:'.
      CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
        EXPORTING
          DOCUMENT          = m_document
        EXCEPTIONS
          NO_DOCUMENT       = 1
          OTHERS            = 2.
      if sy-subrc = 0.  write  'ok'.
      else.             write: 'Err =', sy-subrc.
      endif.
    convert DOM to XML doc (table)     ****
      write: / 'converting DOM TO XML:'.
      CALL FUNCTION 'SDIXML_DOM_TO_XML'
        EXPORTING
          DOCUMENT            = m_document
        PRETTY_PRINT        = ' '
        IMPORTING
          XML_AS_STRING       = w_string
          SIZE                = w_size
        TABLES
          XML_AS_TABLE        = it_xml
        EXCEPTIONS
          NO_DOCUMENT         = 1
          OTHERS              = 2.
      if sy-subrc = 0.   write  'ok'.
      else.              write: 'Err =', sy-subrc.
      endif.
      write: / 'XML as string of size:', w_size, / w_string.
      describe table it_xml lines w_result.
      write: / 'XML as table of', w_result, 'lines:'..
      loop at it_xml into s_xml.
        write s_xml.
      endloop.
      write: / 'end of processing'.
    end of code
    Hope this will be useful.
    regards
    vinod

  • Reading XML file using BAPI  I must use adapters .

    Reading XML file using BAPI and then uploading that xml file data into SAP using BDC.
    I cant take file on to my Application server I am getting the file dynamically from other file server and I need to use BAPis to read data from XML file.please tell me what should be my Import,Export and Tables parameterrs should be.
    Thanks

    Hi,
    Import, export and table parameters for BAPI is required, without that BAPI will not able to collect the data from XML. What you need to do is write a Zprogram and collect the data, store that data in internal table and call the BAPI by passing required parameters.
    Different Scanarios:
    1) Before calling a BAPI write some other program which collects the data from XML and create a UNIX file. Try to get the data from UNIX FILE
    2) If you see the XML tags, data will be in side that tags, try to get the data from XML tags and store that data in one SAP table. You can use the BAPI by fetching the data from table
    3)Create a table and store the data in the table. Use the table in SAP to extract the data.
    BAPI won't work without any parameters, you have to pass some parameters then the BAPI will return some values.
    Hope i am clear.
    Thanks&Regards,
    -Suresh Revuru

  • Retrieve and Read XML Files using Oracle6i Forms

    Dear all .. i have some problem here: How can i retrieve and read a XML files using Oracle6i Forms? What should i do? Thanks - ASAP -

    Several ways - Pick up a copy of the Oracle XDK off of OTN. This provides Java and PL/SQL toolkits for dealing with XML files.
    The PL/SQL one would be in the Database, so you might have to use the Java one of you need to do it on the Forms machine.
    You can use the Java Importer in 6i to create PL/SQL wrappers that you can call from forms into the Java XDK APIs.
    Or of course you can just use the TEXT_IO package to read the XML as a text stream and parse it in your own PL/SQL code...

  • How to read XML file using Automatic ref No

    I need to get the data from the xml file using Automatic reference No.I am a beginner .help me out

    Hi Parthipan,
    An easy way to get started with using XML in LabVIEW is a toolkit called EasyXML -- it's a product from JKI that I helped create
    Thanks,
    -Jim

  • Read XML File Using PL/SQL

    Hi,
    I have to read a XML file using PL/SQL. I am new to this so please explain in easy steps.
    Regards,
    SF

    STEP - 2
    SQL>
    SQL> DECLARE
      2    l_ctx dbms_xmlsave.ctxType ;
      3    l_xml CLOB :=
      4  '<?xml version="1.0" encoding="UTF-8" ?>
      5  <NewDataSet>
      6      <ROW>
      7          <DEPARTMENT>BA52</DEPARTMENT>
      8          <PCS_CONTRACT_TAG>MD-3GSM</PCS_CONTRACT_TAG>
      9          <LOCATION>Australia</LOCATION>
    10          <MAY_2006>21668</MAY_2006>
    11      </ROW>
    12      <ROW>
    13          <DEPARTMENT>BA501</DEPARTMENT>
    14          <PCS_CONTRACT_TAG>MD-3GSM</PCS_CONTRACT_TAG>
    15          <LOCATION>China</LOCATION>
    16          <MAY_2006>8166</MAY_2006>
    17      </ROW>
    18      <ROW>
    19          <DEPARTMENT>BA522</DEPARTMENT>
    20          <PCS_CONTRACT_TAG>MD-3GSM</PCS_CONTRACT_TAG>
    21          <LOCATION>Australia</LOCATION>
    22          <MAY_2006>21668</MAY_2006>
    23      </ROW>
    24  </NewDataSet>' ;
    25  BEGIN
    26      l_ctx := dbms_xmlsave.newContext(targetTable => 'XML_INSERT');
    27      dbms_output.put_line(dbms_xmlsave.insertXML(ctxHdl => l_ctx,
    28                                                  xDoc   => l_xml) ||
    29                           ' rows inserted.');
    30      dbms_xmlsave.closeContext(l_ctx);
    31  END;
    32  /
    3 rows inserted.
    PL/SQL procedure successfully completed.Regards.
    Satyaki De.

  • Read xml file using Acrobat javascript

    Please let me know if a XML file can be read using Acrobat javascript.
    I need to read and store the xml data in a string.
    thanks,
    Sashi

    STEP - 2
    SQL>
    SQL> DECLARE
      2    l_ctx dbms_xmlsave.ctxType ;
      3    l_xml CLOB :=
      4  '<?xml version="1.0" encoding="UTF-8" ?>
      5  <NewDataSet>
      6      <ROW>
      7          <DEPARTMENT>BA52</DEPARTMENT>
      8          <PCS_CONTRACT_TAG>MD-3GSM</PCS_CONTRACT_TAG>
      9          <LOCATION>Australia</LOCATION>
    10          <MAY_2006>21668</MAY_2006>
    11      </ROW>
    12      <ROW>
    13          <DEPARTMENT>BA501</DEPARTMENT>
    14          <PCS_CONTRACT_TAG>MD-3GSM</PCS_CONTRACT_TAG>
    15          <LOCATION>China</LOCATION>
    16          <MAY_2006>8166</MAY_2006>
    17      </ROW>
    18      <ROW>
    19          <DEPARTMENT>BA522</DEPARTMENT>
    20          <PCS_CONTRACT_TAG>MD-3GSM</PCS_CONTRACT_TAG>
    21          <LOCATION>Australia</LOCATION>
    22          <MAY_2006>21668</MAY_2006>
    23      </ROW>
    24  </NewDataSet>' ;
    25  BEGIN
    26      l_ctx := dbms_xmlsave.newContext(targetTable => 'XML_INSERT');
    27      dbms_output.put_line(dbms_xmlsave.insertXML(ctxHdl => l_ctx,
    28                                                  xDoc   => l_xml) ||
    29                           ' rows inserted.');
    30      dbms_xmlsave.closeContext(l_ctx);
    31  END;
    32  /
    3 rows inserted.
    PL/SQL procedure successfully completed.Regards.
    Satyaki De.

  • Reading Xml file using File Adapter

    Hi
    I have added a file adapter to my process to read out a emp.xml from the location C:\inputDir.
    Also i have added transformation activity to map the variables.
    But the problem is iam not able read the values from emp.xml;File adpater giving me as
    empty values;
    Can someone show me a simple example?
    1.my input emp.xml
    <?xml version="1.0" encoding="windows-1252"?>
              <ns0:EmpCollection xmlns="http://TargetNamespace.com/ServiceName" xmlns:ns0="http://xmlns.oracle.com/pcbpel/adapter/db/top/Insert"/>
    <ns0:Emp>
    <ns0:empno>595</ns0:empno>
    <ns0:ename>TestDAY</ns0:ename>
    <ns0:job>ANALYST</ns0:job>
    <ns0:mgr>7369</ns0:mgr>
    <hiredate>2007-11-28</ns0:hiredate>
    <ns0:sal>20000</ns0:sal>
    <ns0:comm>120</ns0:comm>
    <ns0:deptno>20</ns0:deptno>
    </ns0:Emp>
    </ns0:EmpCollection>
    2.Getting output as following empty values
    [2007/01/12 10:20:49]
    Updated variable "InvokeWrite_Write_InputVariable"
    - <InvokeWrite_Write_InputVariable>
    - <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="EmpCollection">
    - <EmpCollection xmlns:ns0="http://xmlns.oracle.com/pcbpel/adapter/db/top/Insert" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/top/Insert">
    - <ns0:Emp>
    <ns0:empno/>
    <ns0:ename/>
    <ns0:job/>
    <ns0:mgr/>
    <ns0:hiredate/>
    <ns0:sal/>
    <ns0:comm/>
    <ns0:deptno/>
    </ns0:Emp>
    </EmpCollection>
    </part>
    </InvokeWrite_Write_InputVariable
    Can someone show me a simple example?
    Thx in adv;
    ismail

    Thx for quick response;
    The following is the XML input for my BPEL process
    <?xml version="1.0" ?>
    <EmpCollection/>
    <Emp>
    <empno>595</empno>
    <ename>TestDAY</ename>
    <job>ANALYST</job>
    <mgr>7369</mgr>
    <hiredate>2007-11-28</hiredate>
    <sal>20000</sal>
    <comm>120</comm>
    <deptno>20</deptno>
    </Emp>
    </EmpCollection>
    The following is the XSd file for ReadAdpater schemafile
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <xs:schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/Select" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/top/Select" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="EmpCollection" type="EmpCollection"/>
    <xs:complexType name="EmpCollection">
    <xs:sequence>
    <xs:element name="Emp" type="Emp" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="Emp">
    <xs:sequence>
    <xs:element name="empno" type="xs:int"/>
    <xs:element name="ename" minOccurs="0" nillable="true">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="10"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="job" minOccurs="0" nillable="true">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="9"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="mgr" type="xs:int" minOccurs="0" nillable="true"/>
    <xs:element name="hiredate" type="xs:dateTime" minOccurs="0" nillable="true"/>
    <xs:element name="sal" type="xs:decimal" minOccurs="0" nillable="true"/>
    <xs:element name="comm" type="xs:decimal" minOccurs="0" nillable="true"/>
    <xs:element name="deptno" type="xs:int" minOccurs="0" nillable="true"/>
    </xs:sequence>
    </xs:complexType>
    <xs:element name="SelectSelect_enoInputParameters" type="SelectSelect_eno"/>
    <xs:complexType name="SelectSelect_eno">
    <xs:sequence>
    <xs:element name="eno" type="xs:int" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>

  • Reading XML file from application server and  put into internal table-4.6C

    Dear All,
    Is there any way of reading XML file from application server to SAP? I am using 4.6C. Function module SCMS_STRING_TO_XSTRING function module is not available. Please suggest.
    Thanks and regards,
    Atanu

    Hi Atanu!
    Simply use the XSLT transformation 'ID'.
    FIELD-SYMBOLS <ls_result> TYPE ANY.
    CREATE DATA lref_data TYPE (your_structure).
    ASSIGN lref_data->* TO <ls_result>.
    CALL TRANSFORMATION id
                        SOURCE XML xmlstr
                        RESULT result = <ls_result>.
    "xmlstr" contains your XML file. Just read it into it via standard I/O operations. "<ls_result>" will contain your DDIC formatted content.
    Best regards
    Torsten

  • I am wondering if there is a way to validate XML file without using .......

    I am wondering if there is a way to validate XML file without using the <!DOCTYPE... but pass in the location of the schema/DTD file as a parameter to a validating method?
    thanks

    None that I know of. The only thing close is to use the EntityResolver interface where you can modify the location of the DTD file before it's being loaded and parsed, but that requires a <!DOCTYPE ...> in the XML file.
    Good luck.

  • Where can I find an example of a vi which reads a xml file using the Labview schema (LVXMLSchema.xsd)?

    Where can I find an example of a vi which reads a xml file using the Labview schema (LVXMLSchema.xsd)?
    �Unflatten From XML� is of little use in parsing because it requires the data type. So it seems that the user has to parse each data value, and then �Unflatten From XML� can help a little.
    I would like to see NI provide a VI for parsing it�s own schema.

    LabVIEW's XML functions are another way of saving data from controls and indicators that is in a more standardized format. If you look at the Unflatten From XML shipping example, it shows taking the data that you would normally send to a Digital Wveform Graph and converting it to XML instead. This data is then unflattend from XML and wired to the graph. Since you know what you wrote to the file, this is an easy thing to do. If what you are looking for is a way to look at any data in any LabVIEW XML file, then you are right, there is not a VI for that. However, I do not believe that that was the intention of the XML functions in the first place.
    By wiriting data in XML, this allows other applications outside of LabVIEW to parse and recognize the dat
    a. In LabVIEW, you would already know the types and can place a generic item of that type. The issue of knowing the type is that you need to know the type of the wire that comes out of the Unflatten function so that the VI will compile correctly. You could always choose a variant value to unflatten and then do some parsing to take the variant a part. Maybe this will help you out.
    See this example for using the Microsoft parser for XML. (http://venus.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_guid=B123AE0CB9FE111EE034080020E74861&p_node=DZ52050&p_submitted=N&p_rank=&p_answer=)
    Randy Hoskin
    Applications Engineer
    National Instruments
    http://www.ni.com/ask

  • Reading large XML file using a file event generator and a JPD process

    I am using a FileEventGenerator and a JPD Subscription process to read a large XML file. The large XML file basically contains repeated XML elements. My understanding is that the file subscription method reads the whole file in memory which causes lots of problem for huge file size like 1MB. Is there a way to read the file size-wise or is there a way to read chunks of data from a large size file..or any other alternative. I would like to process the file in a loop iteration by iteration.

    Hitejain,
    Here are a couple of pointers you could try. One is that the file event generator has a pass by reference (filename) functionality which you could use so that you could do the following inside of your process.
    1) Read file name from the reference
    2) Move the file to a processed directory (so it doesn't get picked up again. Note: I don't know how the embedded archive methods of the file event generator plays with pass by reference.
    3) Open a stream to the file.
    4) Use a SAX or SAX - DOM combined approach to parse your XML while managing the memory usage inside of your process
    There is another possibility which might fit your needs and it is related to the RawData object that BEA provides. If I understand it correctly provides wrapping functionality around a stream object, but depending on your parsing methods might just postpone the problem.
    Hope this helps
    Chris Falling
    Stormforge Software

  • Use jsp to read xml file

    Gents,
    I'm a XML & JSP newbie and try to do the following: I have a xml file which can be opened with a browser so that I can see data (let's say my cd collection). Further I have a xls file which makes the display a little nicer, with colors and so. Now, I want to have a jsp page read this xml file and I'm not very succesfull, while I spent hours and hours on Google, but nothing.
    What I did so far, was:
    - download & install Tomcat 5.5
    - make a dir under webapps\mycdcollection
    - copy my xml files to webapps\mycdcollection
    - make a dir webapps\mycdcollection\WEB-INF
    - make a dir webapps\mycdcollection\WEB-INF\lib
    - copy standard.jar & jstl.jar to BOTH webapps\mycdcollection\WEB-INF\lib as webapps\ROOT\WEB-INF\lib
    Here are my questions:
    - How should my web.xml in webapps\mycdcollection\WEB-INF look like?
    - Should I precompile my jsp? If so, should there be a classes directory somehwere? How should I make my app know that there is a classes directory?
    I'm sure I will have lots more of questions, but if you can get me on the way I'd be very thankful.

    hi,
    u can interact with xml while in jsp. we have jstl (xml) tags to interact with the xml files.
    use the jstl and copy the jar files neede for the jstl in to ur web app folder. u need to copy jstl.jar, standard.jar, jaxen.jar, and optionally (saxpath.jar and xalan.jar) based on the versions of the jstl ur using.
    mail me at [email protected], if u have any problems.
    Here, are some urls' go through with this,
    http://www.roseindia.net/jstl/introduction.shtml
    http://www-128.ibm.com/developerworks/java/library/j-jstl0318/
    http://jcp.org/aboutJava/communityprocess/final/jsr052/index2.html
    regards,
    pavan

  • How to read the attribute of the xml file using jaxb

    Thanks,
    Buddy as i have a issue i have to read the xml file using jaxb and xml file contains this data and i have read the attribute like name , desc and action for a particular menu name pls tell the code how to do this it will be a great favour to me
    thanx in advance
    Rasool
    <contextmenu>
    <menu name='Lead' >
    <menuitem name='newlead' desc='New Lead' action='/leads.do?dispatch=insert' />
    <menuitem name='editlead' desc='Edit Lead' action='' />
    <menuitem name='leadinfo' desc='Lead Information' action='' />
    </menu>
    <menu name='Cases' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    <menu name='Contact' >
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    <menuitem name='' desc='' action='' />
    </menu>
    </contextmenu>

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

Maybe you are looking for

  • DVI to ADC adapter

    This one is a little tricky...i have a 20" Apple Display with an ADC connection.....my friend who owns an older G4 believeed to have a DVI-D and VGA connection wants to buy it but we're wondering if there is any way to hook it up.....I have an Apple

  • Why is the video dropping frames after export?

    http://vimeo.com/65108558 The video in question is in the above link. I am using PP CS5 with a new iMac i7 32gb cuda enabled. When watching the clips in the timeline everything looks normal. This video was encoded to h.264 max render quality with the

  • Dual cards, for more displays

    so this mac pro, currently has an ati X1900 card installed, which has 2 DVI ports on it.  Bottom line, im thinking about maybe having up to 3-4 displays hooked up to this thing symaltaniously.  One of these I may want to be my Old SD 60" TV which onl

  • Estimated Rows Column, when using /*+ gather_plan_statistics*/

    Hi, does anybody know, where the Information of the estimated_rows (e-rows) Output comes from? I would like to auto check, when a explain uses wrong statistics. I know that is inside the dbms_xplan.display.display Package but i would like to use it o

  • PRO*COBOL QUESTION

    Is possible to use the 'join' statement in pro*cobol version 9.2 ?