ForEach Loop - Parsing XML subgroup into Variables
Hi all,I am designing a new ETL process using SSAS.
We have a controller package which receives an XML string at run time into a variable called BatchRequest :-
<Batch>
<Request>
<Name>Filemon</Name>
<Params>
<filepaths>
<Sourcepath>d:\temp</Sourcepath>
<Destpath>D:\temp2</Destpath>
<Archivename>\Archive</Archivename>
</filepaths>
</Params>
</Request>
</Batch>
The Batch can contain a number of Requests and a ForEach Loop is used to parse the text for the Name node and the text for the Params Node into variables RequestName and RequestParams respectively.
however, what I want to be able to do is to take the text for <name> into Requestname but take the entire XML sub string for <Params> into RequestParams.
At the moment I get the text only (e.g. d:\tempd:\temp2\Archive).
The Requestname is used by an XML task within the ForEach loop to retrieve full package path details from an external config file, and hence it only needs to be a keyword.
I played with the idea of including <Params> as a subnode for <Name>, only populating RequestName in the loop parser and then having an XML task which would parse the related parameter string, but i don't know how to tell the XML task that I
want the parameter string where the <Name> is Filemon (in this example).
Can anyone give me some suggestions or pointers?
Thanks
Iain
Iain
Hi idcowden,
Glad to hear that you have resolved the issue on your own. Thank you for sharing the solution.
Regards,
Mike Yin
TechNet Community Support
Similar Messages
-
How to parse xml data into java component
hi
everybody.
i am new with XML, and i am trying to parse xml data into a java application.
can anybody guide me how to do it.
the following is my file.
//MyLogin.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
class MyLogin extends JFrame implements ActionListener
JFrame loginframe;
JLabel labelname;
JLabel labelpassword;
JTextField textname;
JPasswordField textpassword;
JButton okbutton;
String name = "";
FileOutputStream out;
PrintStream p;
Date date;
GregorianCalendar gcal;
GridBagLayout gl;
GridBagConstraints gbc;
public MyLogin()
loginframe = new JFrame("Login");
gl = new GridBagLayout();
gbc = new GridBagConstraints();
labelname = new JLabel("User");
labelpassword = new JLabel("Password");
textname = new JTextField("",9);
textpassword = new JPasswordField(5);
okbutton = new JButton("OK");
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 1;
gbc.gridy = 5;
gl.setConstraints(labelname,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2;
gbc.gridy = 5;
gl.setConstraints(textname,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 1;
gbc.gridy = 10;
gl.setConstraints(labelpassword,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2;
gbc.gridy = 10;
gl.setConstraints(textpassword,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 1;
gbc.gridy = 15;
gl.setConstraints(okbutton,gbc);
Container contentpane = getContentPane();
loginframe.setContentPane(contentpane);
contentpane.setLayout(gl);
contentpane.add(labelname);
contentpane.add(labelpassword);
contentpane.add(textname);
contentpane.add(textpassword);
contentpane.add(okbutton);
okbutton.addActionListener(this);
loginframe.setSize(300,300);
loginframe.setVisible(true);
public static void main(String a[])
new MyLogin();
public void reset()
textname.setText("");
textpassword.setText("");
public void run()
try
String text = textname.getText();
String blank="";
if(text.equals(blank))
System.out.println("First Enter a UserName");
else
if(text != blank)
date = new Date();
gcal = new GregorianCalendar();
gcal.setTime(date);
out = new FileOutputStream("log.txt",true);
p = new PrintStream( out );
name = textname.getText();
String entry = "UserName:- " + name + " Logged in:- " + gcal.get(Calendar.HOUR) + ":" + gcal.get(Calendar.MINUTE) + " Date:- " + gcal.get(Calendar.DATE) + "/" + gcal.get(Calendar.MONTH) + "/" + gcal.get(Calendar.YEAR);
p.println(entry);
System.out.println("Record Saved");
reset();
p.close();
catch (IOException e)
System.err.println("Error writing to file");
public void actionPerformed(ActionEvent ae)
String str = ae.getActionCommand();
if(str.equals("OK"))
run();
//loginframe.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}hi, thanks for ur reply.
i visited that url, i was able to know much about xml.
so now my requirement is DOM.
but i dont know how to code in my existing file.
means i want to know what to link all my textfield to xml file.
can u please help me out. i am confused.
waiting for ur reply -
hi,
I need to load data into tables before loading data I have several folders like a1, a2,a3... each folder 'll contain a several .csv files. I need to load those csv files data into destination based on folder wise
Thanks
AVSyou can use foreachloop for that. It has an option called recursive. So just point it to parent level folder and give recursive option and it will go through all folders
https://www.simple-talk.com/sql/ssis/ssis-basics-introducing-the-foreach-loop-container/
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Parsing SOAP Results into Variables
Can someone assist me in figuring out what way I need to go
to parse SOAP results into an array?
I have setup the <MX:WEBService> correctly, created my
resultEvent(event) handler and faultEvenet(event) handler as
needed. Below is the web service:
<mx:WebService
id="srvGetTagHistory" wsdl="{SOAP_URL}"
result="CreateTagHistory(event)" fault="faultEvenet(event)"
useProxy="false">
<mx:operation name="GetTagHistory" resultFormat="e4x">
<mx:request>
<RSWID>{vRSWID}</RSWID>
</mx:request>
</mx:operation>
</mx:WebService>
This works perfectly. I can return the results of the
webservice to a text area control, and the complete SOAP results
are displayed.
My problem is I cannot and have not figured out how to make
the SOAP results into some type of arraycollection for using in,
lets say, a dataGrid.
Here is an example of a SOAP result for the above webservice:
<NS1:GetTagHistoryResponse
xmlns:NS1="urn:myresaleworldserviceIntf-myresaleworldserver"
xmlns:NS2="urn:myresaleworldserviceIntf" xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="
http://schemas.xmlsoap.org/soap/encoding/">
<NS2:return href="#1"/>
<SOAP-ENC:Array id="1">
<item href="#2"/>
<item href="#9"/>
<item href="#16"/>
<item href="#25"/>
<item href="#29"/>
</SOAP-ENC:Array>
<NS2:rswTagHistory id="2">
<OrderDate>2005-12-08T11:15:24.857-05:00</OrderDate>
<TagType>CB Tags</TagType>
<NS2:ColorDetail href="#3"/>
</NS2:rswTagHistory>
<SOAP-ENC:Array id="3">
<item href="#4"/>
<item href="#5"/>
<item href="#6"/>
<item href="#7"/>
<item href="#8"/>
</SOAP-ENC:Array>
<NS2:rswTagColorDetail id="4">
<TagColor>Lavender</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="5">
<TagColor>Light Blue</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="6">
<TagColor>Green</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="7">
<TagColor>Pink</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="8">
<TagColor>Yellow</TagColor>
<Total>1</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagHistory id="9">
<OrderDate>2005-12-08T11:18:44.233-05:00</OrderDate>
<TagType>CB Tags</TagType>
<NS2:ColorDetail href="#10"/>
</NS2:rswTagHistory>
<SOAP-ENC:Array id="10">
<item href="#11"/>
<item href="#12"/>
<item href="#13"/>
<item href="#14"/>
<item href="#15"/>
</SOAP-ENC:Array>
<NS2:rswTagColorDetail id="11">
<TagColor>Lavender</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="12">
<TagColor>Light Blue</TagColor>
<Total>3</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="13">
<TagColor>Green</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="14">
<TagColor>Pink</TagColor>
<Total>3</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="15">
<TagColor>Yellow</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagHistory id="16">
<OrderDate>2006-08-07T13:56:22.513-05:00</OrderDate>
<TagType>CB Tags</TagType>
<NS2:ColorDetail href="#17"/>
</NS2:rswTagHistory>
<SOAP-ENC:Array id="17">
<item href="#18"/>
<item href="#19"/>
<item href="#20"/>
<item href="#21"/>
<item href="#22"/>
<item href="#23"/>
<item href="#24"/>
</SOAP-ENC:Array>
<NS2:rswTagColorDetail id="18">
<TagColor>Lavender</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="19">
<TagColor>Light Blue</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="20">
<TagColor>Green</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="21">
<TagColor>Orange</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="22">
<TagColor>Pink</TagColor>
<Total>1</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="23">
<TagColor>Red</TagColor>
<Total>2</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="24">
<TagColor>Yellow</TagColor>
<Total>1</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagHistory id="25">
<OrderDate>2007-04-10T12:08:03.950-05:00</OrderDate>
<TagType>CB Tags</TagType>
<NS2:ColorDetail href="#26"/>
</NS2:rswTagHistory>
<SOAP-ENC:Array id="26">
<item href="#27"/>
<item href="#28"/>
</SOAP-ENC:Array>
<NS2:rswTagColorDetail id="27">
<TagColor>Light Blue</TagColor>
<Total>3</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagColorDetail id="28">
<TagColor>Green</TagColor>
<Total>1</Total>
</NS2:rswTagColorDetail>
<NS2:rswTagHistory id="29">
<OrderDate>2007-12-19T12:52:30.883-05:00</OrderDate>
<TagType>Thermal Tags</TagType>
<NS2:ColorDetail href="#30"/>
</NS2:rswTagHistory>
<SOAP-ENC:Array id="30"/>
</NS1:GetTagHistoryResponse>
Any assistance to this issue would be greatly appreciated.If you have set resultFormat="e4x" than you can handle the
result very easily.
I guess you already find out that your result is in
event.result.
Your example is too hard to parse by human.
You can read:
http://livedocs.adobe.com/labs/flex3/html/help.html?content=13_Working_with_XML_01.html
Especially: Traversing XML structures and Using XML
namespaces
I hope this will help -
Parsing xml data into oracle database
Oracle ACEs,
We got a requirement that needs to load xml data into oracle db. Is it possible to load xml data into oracle db using built-in package. Is Oracle provides one ?
Our database version is Oracle 9i.
Your help in this regard is highly appreciated.
Many Thanks.Check this out.
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_xmlsav.htm#1008593 -
Download created XML File in batch mode // Parse XML file into single lines
Hello!
I upload a CSV file and based on that CSV file I create an XML "object". First I uploaded and downloaded it via gui frontendclass, but as it has to be run in a batch in the night I need to upload and download the data via OPEN DATASET.
The import and transformation of the CSV file works fine, also the transfer into an itab with the same structure as a CSV line is ok. I also create the XML file, which could be downloaded easily with gui-download but it is not permittet.
Import of data: I scan the folder and get the filenames into a itab, I loop over that itab and read the single files like this:
OPEN DATASET ls_convert_batch FOR INPUT IN TEXT MODE ENCODING DEFAULT.
CLEAR tab.
IF sy-subrc = 0.
DO.
READ DATASET ls_convert_batch INTO line.
IF sy-subrc <> 0.
EXIT.
ELSE.
CLEAR tmptab.
SPLIT line AT ';' INTO tmptab-product
tmptab-contract
tmptab-extagent.
APPEND tmptab TO tab.
ENDIF.
ENDDO.
ENDIF.
The XML file has a strucutre like
<file>
- <file formant_no="1.1" format_date="02.10.2003">
<status>V</status>
<number>001001025</numbner>
<name>Schmeisser,Christof</name>
- <details>
- <detail>
<contract>00000003494</contract>
<name>Schmeisser, Christof</name>
<invoice_no>000000003840</invoice_no>
<due_date>20100601</due_date>
<amount>140,00</amount>
</detail>
- <detail>
<contract>00000003495</contract>
<name>Schmeisser, Christof</name>
<invoice_no>000000003841</invoice_no>
<due_date>20100601</due_date>
<amount>130,00</amount>
</detail>
- </details>
<elements>2</elements>
<amount_overall>270</amount_overall>
</file>
At the moment I download it like this:
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = filename
filetype = 'BIN'
* CONFIRM_OVERWRITE = '0'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF sy-subrc = 0.
lv_create_counter = lv_create_counter + 1.
ENDIF.
But I need to download it via OPEN TRANSFER CLOSE Dataset as it has to run in batch mode.
Anyone has an idea? I am really desperate here. One idea would be to parse the single lines into a string and then create the XML file line by line as text and save it with ending XML, should work. But I don't know how!
Thank you very much in advance,
kind regards from Tallinn, Estonia,
Christof!
Edited by: Christof Schmeisser on Nov 25, 2010 7:51 PM
I edited the heading, would be too general and missleading!Tipos Pools
TYPE-POOLS: ixml.
CLASS cl_ixml DEFINITION LOAD.
TYPES: BEGIN OF xml_node_type,
node TYPE char50,
vlnode TYPE string,
END OF xml_node_type,
BEGIN OF xml_line_type,
data(256) TYPE x,
END OF xml_line_type.
Tabelas Internas
DATA: ti_xml_node TYPE TABLE OF xml_node_type.
Variáveis TYPE REF
*Type REF para utilizar no XML
DATA: ixml_type TYPE REF TO if_ixml,
streamfactory_type TYPE REF TO if_ixml_stream_factory,
ostream_type TYPE REF TO if_ixml_ostream,
istream_type TYPE REF TO if_ixml_istream,
parser_type TYPE REF TO if_ixml_parser,
renderer_type TYPE REF TO if_ixml_renderer,
document_type TYPE REF TO if_ixml_document,
encoding_type TYPE REF TO if_ixml_encoding,
node_type TYPE REF TO if_ixml_node,
element_dtrans_type TYPE REF TO if_ixml_element,
element_xml_in_type TYPE REF TO if_ixml_element,
element_roteiros_type TYPE REF TO if_ixml_element,
element_roteiro_type TYPE REF TO if_ixml_element,
element_vias_type TYPE REF TO if_ixml_element,
element_via_type TYPE REF TO if_ixml_element,
element_dummy_type TYPE REF TO if_ixml_element,
gw_xml_node TYPE TABLE OF xml_node_type,
gw_xml_node_ret TYPE TABLE OF xml_node_type,
gw_xml_node_err TYPE TABLE OF xml_node_type,
gw_xml_node_xml TYPE TABLE OF xml_node_type,
gw_xml_table TYPE TABLE OF xml_line_type,
gw_xml_table2 TYPE TABLE OF xml_line_type,
gs_xml_node TYPE xml_node_type, "WA para leitura do xml
gs_xml_node_ret TYPE xml_node_type, "WA para leitura do xml retorno
gs_xml_node_err TYPE xml_node_type, "WA para leitura do xml erro
gs_xml_node_xml TYPE xml_node_type, "WA para leitura do xml info sucesso
gs_xml_table2 TYPE xml_line_type. "WA para importar xml
Variáveis do Programa
DATA: l_value TYPE string,
l_rc TYPE i,
l_xml_size TYPE i,
cod_cartaorepom TYPE char20 VALUE '123456789',
v_caminho_exp TYPE string VALUE 'C:TEMP',
v_salvaarquivo TYPE string,
v_nomearquivo TYPE string,
w_nodetext TYPE string,
v_roteiros TYPE string,
v_roteiro TYPE string,
v_roteiro_codigo TYPE string,
v_percurso_codigo TYPE string,
v_percurso_descricao TYPE string,
v_cidade_origem TYPE string,
v_estado_origem TYPE string,
v_cidade_destino TYPE string,
v_estado_destino TYPE string,
v_transporte_tipo TYPE string,
v_cartao_taxa TYPE string,
v_cobra_taxa TYPE string.
Constants
CONSTANTS: cc_39 TYPE string VALUE '39', " Numero 39.
cc_dt_trans TYPE string VALUE 'data_transfer'," document_type(name)
cc_metodo_cod TYPE string VALUE 'metodo_codigo'," document_type(name)
cc_xml_in TYPE string VALUE 'xml_in'," document_type(name)
cc_ct_tx_ativ TYPE string VALUE 'cartao_taxa_ativacao'," document_type(name)
cc_cartao TYPE string VALUE 'cartao', " Parâmetro Perform.
cc_xml TYPE string VALUE '.XML'," extenção
cc_bin TYPE char10 VALUE 'BIN'." filetype
START-OF-SELECTION.
PERFORM yf_inicia_criacao_xml USING cc_39.
element_roteiro_type = document_type->create_simple_element(
name = cc_ct_tx_ativ
parent = element_xml_in_type ).
PERFORM yf_dummy_roteiro USING cod_cartaorepom cc_cartao.
PERFORM yf_finaliza_xml.
PERFORM yf_exporta_xml USING v_caminho_exp.
PERFORM yf_convert_xml_to_itab TABLES gw_xml_node_ret
USING v_salvaarquivo.
END-OF-SELECTION.
*& Form yf_inicia_criacao_xml
text
-->VALUE(P_0783) text
FORM yf_inicia_criacao_xml USING value(p_0783).
DATA: s_encoding_type TYPE string VALUE 'ISO-8859-1'.
Cria o ixml factory
ixml_type = cl_ixml=>create( ).
*Cria o objeto com modelo
document_type = ixml_type->create_document( ).
*Cria o cabeçalho encoding="iso-8859-1"
encoding_type = ixml_type->create_encoding( byte_order = 0
character_set = s_encoding_type ).
*Cria o root "DATA_TRANSFER"
element_dtrans_type = document_type->create_simple_element(
name = cc_dt_trans
parent = document_type ).
*Cria o node "METODO_CODIGO" e preenche com um valor passado no L_VALUE
l_value = p_0783.
CONDENSE l_value.
element_dummy_type = document_type->create_simple_element(
name = cc_metodo_cod
value = l_value
parent = element_dtrans_type ).
*Cria o node "XML_IN"
element_xml_in_type = document_type->create_simple_element(
name = cc_xml_in
parent = element_dtrans_type ).
ENDFORM. " yf_inicia_criacao_xml
*& Form yf_dummy_roteiro
text
-->VALUE(P_0996) text
-->VALUE(P_0997) text
FORM yf_dummy_roteiro USING value(p_0996)
value(p_0997).
l_value = p_0996.
CONDENSE l_value.
element_dummy_type = document_type->create_simple_element(
name = p_0997
value = l_value
parent = element_roteiro_type ).
ENDFORM. " yf_dummy_roteiro
*& Form yf_finaliza_xml
text
FORM yf_finaliza_xml.
*Cria o stream factory
streamfactory_type = ixml_type->create_stream_factory( ).
*Conecta a internal table de XML com o stream factory
ostream_type = streamfactory_type->create_ostream_itable( table = gw_xml_table ).
CALL METHOD ostream_type->set_encoding
EXPORTING
encoding = encoding_type.
*Rendering the document
renderer_type = ixml_type->create_renderer( ostream = ostream_type
document = document_type ).
l_rc = renderer_type->render( ).
*Salva o documento XML
l_xml_size = ostream_type->get_num_written_raw( ).
ENDFORM. " yf_finaliza_xml
*& Form yf_exporta_xml
text
-->VALUE(P_0783) text
FORM yf_exporta_xml USING value(p_0783).
CONCATENATE cod_cartaorepom
sy-datum
sy-uzeit
cc_xml
INTO v_nomearquivo.
CONCATENATE p_0783
v_nomearquivo
INTO v_salvaarquivo.
TRANSLATE v_nomearquivo TO UPPER CASE.
*Exporta o XML
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = v_salvaarquivo
filetype = cc_bin
CHANGING
data_tab = gw_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc = 0.
PERFORM yf_sapgui_progress_indicator USING cc_msg_xml_ok.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " yf_exporta_xml
*& Form yf_convert_xml_to_itab
text
-->P_GW_XML_NODE_RET text
-->P_FILENAME text
FORM yf_convert_xml_to_itab TABLES p_gw_xml_node_ret LIKE gw_xml_node
USING p_filename.
DATA l_count.
ixml_type = cl_ixml=>create( ).
Now Create Stream Factory
streamfactory_type = ixml_type->create_stream_factory( ).
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = p_filename
filetype = cc_bin
IMPORTING
filelength = l_xml_size
CHANGING
data_tab = gw_xml_table2
EXCEPTIONS
OTHERS = 19.
IF sy-subrc = 0.
istream_type = streamfactory_type->create_istream_itable( table = gw_xml_table2
size = l_xml_size ).
document_type = ixml_type->create_document( ).
parser_type = ixml_type->create_parser( stream_factory = streamfactory_type
istream = istream_type
document = document_type ).
IF parser_type->parse( ) NE 0.
IF parser_type->num_errors( ) NE 0.
l_count = parser_type->num_errors( ).
ENDIF.
ENDIF.
CALL METHOD istream_type->close( ).
CLEAR istream_type.
node_type = document_type.
PERFORM yf_get_data USING node_type.
p_gw_xml_node_ret[] = gw_xml_node[].
CLEAR gw_xml_node[].
ENDIF.
ENDFORM. " yf_convert_xml_to_itab
*& Form yf_get_data
text
-->VALUE(X_NODE) text
FORM yf_get_data USING value(x_node) TYPE REF TO if_ixml_node.
DATA: indent TYPE i.
DATA: ptext TYPE REF TO if_ixml_text.
DATA: string TYPE string.
DATA: temp_string(100).
CASE x_node->get_type( ).
WHEN if_ixml_node=>co_node_element.
string = x_node->get_name( ).
w_nodetext = string.
CLEAR string.
string = x_node->get_value( ).
IF NOT w_nodetext IS INITIAL OR
NOT string IS INITIAL.
gs_xml_node-node = w_nodetext.
gs_xml_node-vlnode = string.
IF NOT gs_xml_node-vlnode IS INITIAL.
APPEND gs_xml_node TO gw_xml_node.
CLEAR gs_xml_node.
ENDIF.
ENDIF.
ENDCASE.
Get the next child
x_node = x_node->get_first_child( ).
Recurse
WHILE NOT x_node IS INITIAL.
PERFORM yf_get_data USING x_node.
x_node = x_node->get_next( ).
ENDWHILE.
ENDFORM. "yf_get_data -
Help: How to parse XML string into Node Context
Hi Experts,
I am trying to work with a web dynpro for java application which calls a Web Service. I can call the web service successfully, however I have a problem on interpreting the response result into table. The response result is in (XML) string format, like this:
I followed this , but it resulted to an error:
com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Name expected: 0x20(:main:, row:158, col:59)(:main:, row=158, col=59) -> com.sap.engine.lib.xml.parser.ParserException: Name expected: 0x20(:main:, row:158, col:59)
do anyone of you had a similar experience and were able to resolve it, please post it here. it will be highly appreciated. thanks in advance.Try this :
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new org.xml.sax.InputSource(new StringReader(strXml)));Hope this helps. -
Difficulty parsing XML document into query object
Background: Using CFMX 6.1 to take an XML file exported from
MS-Access and parse it into a query object.
Problem: Of the 6 columns defined in the target query, one of
the columns is only populated in the XML file a very low percentage
of the time. When trying to populate the column for a record that
has no volume I was getting the following error:
Element KEY6.XMLTEXT is undefined in a Java object of type
class coldfusion.xml.XmlNodeMap referenced as...
To get around this I made this code change:
Before
<cfset temp = QuerySetCell(mcquery, "CuKey6",
#mydoc.root.dataroot.qTop1000
.Key6.XmlText#, #i#)>
After
<cfif
StructKeyExists(mydoc.root.dataroot.qTop1000.XMLAttributes,"Key6")>
<cfset temp = QuerySetCell(mcquery, "CuKey6",
#mydoc.root.dataroot.qTop1000
.Key6.XmlText#, #i#)>
</cfif>
The new code gets around the error, but when the template is
executed, columns that DO have values
show up as "[empty string]".
I am trying to figure out why when the record has a actual
value it is now overwritten instead of populated
normally?Use XmlChildren[1], XmlChildren[2],... etc., in place of
Key1, Key2, etc. -
Parsing XML data into MySQL database
I need to parse data from an xml document rsiding on amother
server into a mysql database residing on my server, so that I can
pull data into a php site.
Any help? Mybe there's a commercial script or something?
I would also need to update the data daily
Thanks!!Check this out.
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_xmlsav.htm#1008593 -
Script for parsing xml data and inserting in DB
Thank you for reading.
I have the following example XML in an XML file. I need to write a script that can insert this data into an Oracle table. The table does not have primary keys. The data just needs to be inserted.
I do not have xsd file in this scenario. Please suggest how to modify Method 1 https://community.oracle.com/thread/1115266?tstart=0 mentioned so that I can call the XML mentioned below and insert into a table
Method 1
Create or replace procedure parse_xml is
l_bfile BFILE;
l_clob CLOB;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
l_nl dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
l_file dbms_xmldom.DOMNodeList;
l_filen dbms_xmldom.DOMNode;
lv_value VARCHAR2(1000);
l_ch dbms_xmldom.DOMNode;
l_partname varchar2(100);
l_filename varchar2(1000);
l_temp VARCHAR2(1000);
TYPE tab_type IS TABLE OF tab_software_parts%ROWTYPE;
t_tab tab_type := tab_type();
BEGIN
l_bfile := BFileName('DIR1', 'SoftwareParts.xml');
dbms_lob.createtemporary(l_clob, cache=>FALSE);
dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
dbms_lob.loadFromFile(dest_lob => l_clob, src_lob => l_bfile, amount => dbms_lob.getLength(l_bfile));
dbms_lob.close(l_bfile);
dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY''');
l_parser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(l_parser, l_clob);
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part');
FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
l_n := dbms_xmldom.item(l_nl, cur_emp);
t_tab.extend;
dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname);
t_tab(t_tab.last).partname := l_partname;
l_file := dbms_xslprocessor.selectNodes(l_n,'Files/FileName');
FOR cur_ch IN 0 .. dbms_xmldom.getLength(l_file) - 1 LOOP
l_ch := dbms_xmldom.item(l_file, cur_ch);
lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_ch));
if t_tab(t_tab.last).partname is null then t_tab(t_tab.last).partname := l_partname; end if;
t_tab(t_tab.last).filename := lv_value;
t_tab.extend;
END LOOP;
END LOOP;
t_tab.delete(t_tab.last);
FOR cur_emp IN t_tab.first .. t_tab.last LOOP
if t_tab(cur_emp).partname is not null and t_tab(cur_emp).filename is not null then
INSERT INTO tab_software_parts
VALUES
(t_tab(cur_emp).partname, t_tab(cur_emp).filename);
end if;
END LOOP;
COMMIT;
dbms_xmldom.freeDocument(l_doc);
EXCEPTION
WHEN OTHERS THEN
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
END;
<TWObject className="TWObject">
<array size="240">
<item>
<variable type="QuestionDetail">
<questionId type="String"><![CDATA[30]]></questionId>
<questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
<country type="String"><![CDATA[GB]]></country>
<questionText type="String"><![CDATA[Please indicate]]></questionText>
<optionType type="String"><![CDATA[RadioButton]]></optionType>
<answerOptions type="String[]">
<item><![CDATA[Yes]]></item>
<item><![CDATA[No]]></item>
</answerOptions>
<ruleId type="String"><![CDATA[CRP_GB001]]></ruleId>
<parentQuestionId type="String"></parentQuestionId>
<parentQuestionResp type="String"></parentQuestionResp>
</variable>
</item>
<item>
<variable type="QuestionDetail">
<questionId type="String"><![CDATA[40]]></questionId>
<questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
<country type="String"><![CDATA[DE]]></country>
<questionText type="String"><![CDATA[Please indicate]]></questionText>
<optionType type="String"><![CDATA[RadioButton]]></optionType>
<answerOptions type="String[]">
<item><![CDATA[Yes]]></item>
<item><![CDATA[No]]></item>
</answerOptions>
<ruleId type="String"><![CDATA[CRP_Q0001]]></ruleId>
<parentQuestionId type="String"></parentQuestionId>
<parentQuestionResp type="String"></parentQuestionResp>
</variable>
</item>
</array>
</TWObject>Reposted as
Script to parse XML data into Oracle DB -
Parse XML and Output to JSP page
I have a number of XML documents which are all formatted in the same way, just with different information in the fields.
I wish to parse the XML documents using DOM and output them to an XML page.
How would i go about doing this?
If you could write a small example or any websites that you think might help.
Thanks.I have the parsing working but i cant seem to figure out how to get information out of the parsed document and into variables.
This is a sample of my XML file
<?xml version="1.0"?>
<product code="QB-1226-AB">
<productName>Professional Floodlights</productName>
<description>PIR floodlights that are designed for professional installation. A faulty light requiring a return visit will cost far more than a quality light does in the first place. 3 year guarantee.</description>
<price>120</price>
<manufacturer>Black and Decker</manufacturer>
</product>I can get the productCode value out without any problems using
String name = attrs.getValue("code");
But if i try the same for any of the others i get null. I can accomplish this using DOM easily but i cant find anything at all about getting values out of it using SAX.
Any help would be greatly appreciated. -
Rendering xml-table into logical filename in SAP R/3
Hi,
I am trying to translate an xml-table with bytes into a logical filepath in SAP R3.
Do I have to use the method gui-download or shall I loop the internal xml-table?
When I tried to loop the xml-table into a structure, and then transfering the structure into the logical filename, I get problems with the line breaks in my xml-file. How do I get the lines to break exactly the same as I wrote them in my ABAP-code?
Edited by: Kristina Hellberg on Jan 10, 2008 4:24 PMI believe you posted in the wrong forum.
This forum is dedicated to development and deployment of .Net applications that connect and interact with BusinessObjects Enterprise, BusinessObjects Edge, or Crystal Reports Server. This includes the development of applications using the BusinessObjects Enterprise, Report Application Server, Report Engine, and Web Services SDKs.
Ludek -
Using an ssis variable object as a data source in a foreach loop container
hi we run 2012 std. I have an ssis var of type object that is hydrated from a dynamic query in an execute sql task. I can count on one thing in this object and that is that ID will always be the first "col" on each "row".
Otherwise, resultset can contain a variety of things based on params passed to this sub pkg.
I'd like to introduce a for each loop on this object and tap into index 0, ie the id column.
The first question is "will I be able to parse this object's id in a for each component?".
In the for each loop container properties, I c an item enumerator, ado enumerator, ado.net schema rowset and variable enumerator as enumerator choices. Which do I want if the answer to the 1st question is yes?hoping 2 avoid a data flow. I wonder if what u r saying is that I cannot use an felc to do this. Or if u r showing one of many alternatives.
Sorry, bad title. I just changed that.
I just tried foreach from variable enumerator and aborted with a message that said my variable "coll" doesn't have an enumerator. Going 2 try some of the other choices.
I just tried ado enumerator and from what I can c it isn't actually iterating thru my resultset even once.
I just tried a foreach item enumerator giving "column 0" a data type that matches my ID but from what I can tell the component isn't iterating thru my collection.
ado.net schema rowset doesn't look inviting at all in that it looks like it wants to go back to the db. Not what I had in mind having already gotten this resultset into memory.
according to this article u r supposed to be able to do this using ado enumerator
social.technet.microsoft.com slash wiki slash articles slash sis-looping-over-object-variables-with-as-ado-enumeration-in-foreach-loop-container.aspx -
I have a script task written in C# that creates an array of strings "arrayFields" after parsing a text file. It saves the array of strings in a DTS variable.
Each row in array represents a row is comma separated and is a row that must be inserted into a table. For example,
X and Z are fields in the table
X1, X2,....Xn
Z1,Z2,...Zn
I am using a Foreach Loop to grab each row and then Execute SQL Task to take each row from the array and insert each field per row in a table,
The SQL is something like,
INSERT dbo.table values(field1, field2,...fieldn) arrayFields?
What should this this INSERT look like?I guess you implemented
Shredding a Recordset
Based on what I understood (correct me if I am wrong) you have difficulties mapping the input parameters, if so here is the guide
http://www.sqlis.com/sqlis/post/The-Execute-SQL-Task.aspx
In short it might look like
INSERT dbo.table (ColumnA, ColumnB,...) VALUES (?,?...)
The syntax for the T-SQL INSERT is http://technet.microsoft.com/en-us/library/dd776381%28v=sql.105%29.aspx
Arthur
MyBlog
Twitter -
I know I've REALLY struggled with this before. I just don't understand why this has to be soooooo difficult.
I can very easily do a straight Data Pump of a .xlsX File into a SQL Server Table using a normal Excel Connection and a normal Excel Source...simply converting Unicode to DT_STR and then using an OLE DB Destination of the SQL Server Table.
If I want to make the SSIS Package a little more flexible by allowing multiple .xlsX spreadsheets to be pumped in by using a Foreach Loop Container, the whole SSIS Package seems to go to hell in a hand basket. I simply do the following...
Put the Data Flow Task within the Foreach Loop Container
Add the Variable Mapping Variable User::FilePath that I defined as a Variable and a string within the FOreach Loop Container
I change the Excel Connection and its Expression to be ExcelFilePath ==> @[User::FilePath]
I then try and change the Excel Source and its Data Access Mode to Table Name or view name variable and provide the Variable Name User::FilePath
And that's when I run into trouble...
Exception from HRESULT: 0xC02020E8
Error at Data Flow Task [Excel Source [56]]:SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occured. Error code: 0x80004005.
Error at Data Flow Task [Excel Source [56]]: Opening a rowset for "...(the EXACT Path and .xlsx File Name)...". Check that the object exists in the database. (And I know it's there!!!)
I don't understand by adding a Foreach Loop Container to try and make this as efficient as possible has caused such an error unless I'm overlooking something. I have even tried delaying my validations and that doesn't seem to help.
I have looked hard in Google and even YouTube to try and find a solution for this but for the life of me I cannot seem to find anything on pumping a .xlsX file into SQL Server using a Foreach Loop Container.
Can ANYONE please help me out here? I'm at the end of my rope trying to get this to work. I think the last time I was in this quandry, trying to pump a .xlsX File into a SQL Server Table using a Foreach Loop Container in SSIS, I actually wrote a C# Script
to write the contents of the .xlsX File into a .csv File and then Actually used the .csv File to pump the data into a SQL Server Table.
Thanks for your review and am hoping and praying for a reply and solution.Hi ITBobbyP,
If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
If in this scenario, please refer to the following tips:
The Foreach Loop container should be configured as shown below:
Enumerator: Foreach ADO.NET Schema Rowset Enumerator
Connection String: The OLE DB Connection String for the excel file.
Schema: Tables.
In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
The connection string for Excel Connection Manager is the original one, we needn’t make any change.
Change Table Name or View name to the variable Sheet_Name.
If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Maybe you are looking for
-
Targeting Dynamic Text Box inside moviecip with variable
Hi, How does one target a dynamic text box to change the border color inside of a movie clip? Example below which does not work theName = ("answerPrint" + arryCount); boxName = ("box" + (arryCount+1)); _root.pagePrintPartA[theName][boxName].border =
-
Related about query (I am in problem)
Hey friends ,I am using 9i release 1.I seen library cache mishes high and Now i want to know the query by which it is missing .I know i have to find out particular time and after that V$sql for query but i am not sure exactly How to do it.I am in pro
-
Oracle UTL_SMTP junk mail problem
hi friends i have function; F_MAIL_GONDER which always send mail in junk. how can we send mail to inbox correctly not to junk box? FUNCTION F_MAIL_GONDER MAILICERIGI VARCHAR2, MAILKONUSU VARCHAR2, GONDERENKISI
-
HT1212 How to get my phone unlock?
Help me get my phone unlock please
-
HR:Performance Appraisal:Can we Hide Prior Year Plans
Is it possible to hide prior year performance appraisal plans from the Self service Talent Management Task List through personalization. If so How to accomplish ?. Regards,