Reading complex XML file in flex
I have searched the web but found very primitive xml
examples. I want to read a complex xml file which through
httpservice .
The xml file is ultimately going to become dataProvider of a
tree. But I have no idea how to traverse this xml file. mentioned
under are the xml file and HTTPService tag.
I want to traverse it in the resultHandler function.
Thank you very much
Yes, as Greg says, use e4x.
To do this you must set the HTTPService resultFormat="e4x";
In you handler, do:
var xmlResult= XML(event.result);
trace(xmlResult.toXMLString());
and away you go.
Tracy
Similar Messages
-
Flex Photoshop Panel won't read local XML file
I've created a panel for Photoshop which reads an XML file to populate some controls. When run from Flash Builder 4 through the web browser it works just fine, but when run from within Photoshop the XML file is not being read. Uploading the XML file to a web site and referencing it via URL in the panel works sucessfully in both the web browser and from within Photoshop, suggesting some type of security issue.
The Panel Developer's Guide FAQ talks about giving the Adobe Flash Player trust permissions by creating .cfg files that reference the folder the panel is running from.
I have created these .cfg files and placed them in both:
/Library/Application Support/Macromedia/FlashPlayerTrust
and also in:
USER/Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust
but the problem remains.
Environment:
Mac OSX 10.6
Photoshop CS5
Flex Builder 4
Flex SDK 3.5
Any help/suggestions appreciated.I had the same issue but I got it to work. I figure I update this thread in case somebody is trying to do the same. I didn't need to use javascript in order to load the XML. Just create the XML object:
<mx:XML id="myXML" source="data.xml" format="e4x"/>
Remeber to use e4x. The in the AS3 code I bound it to a var:
private var _XML :XML;
_XML = myXML;
then....
private var _itemsXMLList :XMLList;
_itemsXMLList = _XML.node;
Don't forget to add "-use-network=false" to the properties > Flex compiler > additional compiler arguments.
Hope that helps. -
Help Required on Reading an External XML file in flex
Hi Experts
I want some help regarding flex.
I want to read an external xml file in flex and want to show
different datas in different components
So bacically i need what is the procedure to call an external
xml file and the procedure to catch the value of the xml tags and
the option (options means ex: "id" or "type inside" "row" tag ) in
side the xml file.
Here is My xml file named "skn_organ.xml"
<?xml version="1.0" encoding="UTF-8"?>
<slide>
<r>7</r>
<c>8</c>
<row id="A01" type="g">
<organ>Skn</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="A02" type="g">
<organ>Brt</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="A03" type="g">
<organ>Spl</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="A04" type="g">
<organ>Lnode</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="A05" type="g">
<organ>Ske</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="A06" type="g">
<organ>Lun</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="A07" type="g">
<organ>Sgl</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="A08" type="g">
<organ>Liv</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="B01" type="g">
<organ>Gal</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="B02" type="g">
<organ>Pan</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="B03" type="g">
<organ>Ton</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="B04" type="g">
<organ>Eso</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="B05" type="g">
<organ>Sto</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="B06" type="g">
<organ>Sto</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="B07" type="g">
<organ>Sbl</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="B08" type="g">
<organ>Col</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="C01" type="g">
<organ>Skn</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="C02" type="g">
<organ>Brt</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="C03" type="g">
<organ>Spl</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="C04" type="g">
<organ>Lnode</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="C05" type="g">
<organ>Ske</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="C06" type="g">
<organ>Lun</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="C07" type="g">
<organ>Sgl</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="C08" type="g">
<organ>Liv</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="D01" type="g">
<organ>Gal</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="D02" type="g">
<organ>Pan</organ>
<link>
http://www.designgarbage.com</link>
</row>
<row id="D03" type="g">
<organ>Ton</organ>
<link>
http://www.designgarbage.com</link>
</row>
</slide>Hi sanjivsutar,
Put your xml file under folder "assets", the application demo
is as following
====================================================================
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
initialize="init()">
<mx:Script>
<![CDATA[
private var mainXML:XML;
private var loader:URLLoader;
private function init():void {
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest('assets/skn_organ.xml'));
private function onComplete(evt:Event):void {
mainXML = new XML(loader.data)
out.text += "xml loaded, using E4X syntax: \n\n";
out.text += "Row 1: "+mainXML.row[0]+"\n"
out.text += "Row 6: organ = "+mainXML.row[5].organ+"\n"
out.text += "Row(id='D02'): link =
"+mainXML.row.(@id=="D02").link+"\n"
]]>
</mx:Script>
<mx:TextArea id="out" width="400" height="300"/>
</mx:Application>
======================================================================
Jeffrey -
Reading an xml file in actionscript using flex3
plzz tell me how to read an xml file in actionscript using flex3.......
One possible option to parse an xml-file to a flex XML object:
public function parseConXML(source:String):void
xmlLoader = new URLLoader();
xmlLoader.load(new URLRequest(source));
// Eventlistener: if URL loaded --> onLoadComplete function
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadComplete);
public function xmlLoadComplete(evt:Event):void{
var xml:XML = new XML();
// ignore comments in XML-File
XML.ignoreComments = true;
//ignore whitespaces in XML-File
XML.ignoreWhitespace = true;
// XML-Objekt erstellen
xml = new XML(evt.target.data);
//AFTERWARDS use your xml as your wish -
Hi,
I am trying to read XSL-FO file in flex like XML. but i could not. This file has tags with namespace means (fo:),so i could not find the way to read these tags. Is there anyway i can read XSL-FO File in Flex.
Example : <fo:layout-master-set>
Thanks In Advance.I posted an article on how to parse XML structures that use namespaces a while back, please visit this link: http://blog.wisebisoft.com/2009/07/15/parsing-xml-structures-that-use-namespaces/ Since the XLS-FO file is just another XML structure, you should be able to parse it the same way as you'd parse any other XML structure. Good luck.
-
How to read a xml file in ActionScript
In mxml we can find <mx:Model> to load a xml and using
it easily. But in ActionScript, there is no such a Class about this
function(only implemented in mxml), so how to load a xml file in a
easy way in ActionScript?
And I tried using HTTPService, but I think that is not the
best solution because the code do not know when the hander get the
data in xml then the function return that value.
So please someone give a easy way as <mx:model> in mxml
to read the xml file?
Thank you very much.Flex is asynchronous so HTTPService with result event handler
is the way to go. -
Decrypt and unzip a File + read a XML file received into the ZIP
Hello,
I need your help to develop some a complex Biztalk application.
Here're my needs :
Our Busness partner send us a zip file cripted with a standard PGP(Pretty Goof Privacy).
The zip containts an XML file that i have to deal it, and some attachments file(PDF).
So i need to know what's the best approach for the developpement of my application.
I want to decrypt the ZIP and then Unzip the file and them read the XML file received in the zip.
Knowimg that we already have the pipeline compenent to dectypt the file with the strandar PGP and an other pipeline compenent to unzip the File.
Thank youHi ,
Try this code to unzip the file and send the xml message .If u face issue let me know
namespace BizTalk.Pipeline.Component.DisUnzip
using System;
using System.IO;
using System.Text;
using System.Drawing;
using System.Resources;
using System.Reflection;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using Microsoft.BizTalk.Message.Interop;
using Microsoft.BizTalk.Component.Interop;
using Microsoft.BizTalk.Component;
using Microsoft.BizTalk.Messaging;
using Ionic.Zip;
using System.IO.Compression;
[ComponentCategory(CategoryTypes.CATID_PipelineComponent)]
[System.Runtime.InteropServices.Guid("8bef7aa9-5da5-4d62-ac5b-03af2fb9d280")]
[ComponentCategory(CategoryTypes.CATID_DisassemblingParser)]
public class DisUnzip : Microsoft.BizTalk.Component.Interop.IDisassemblerComponent, IBaseComponent, IPersistPropertyBag, IComponentUI
private System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager("BizTalk.Pipeline.Component.DisUnzip.DisUnzip", Assembly.GetExecutingAssembly());
#region IBaseComponent members
/// <summary>
/// Name of the component
/// </summary>
[Browsable(false)]
public string Name
get
return resourceManager.GetString("COMPONENTNAME", System.Globalization.CultureInfo.InvariantCulture);
/// <summary>
/// Version of the component
/// </summary>
[Browsable(false)]
public string Version
get
return resourceManager.GetString("COMPONENTVERSION", System.Globalization.CultureInfo.InvariantCulture);
/// <summary>
/// Description of the component
/// </summary>
[Browsable(false)]
public string Description
get
return resourceManager.GetString("COMPONENTDESCRIPTION", System.Globalization.CultureInfo.InvariantCulture);
#endregion
#region IPersistPropertyBag members
/// <summary>
/// Gets class ID of component for usage from unmanaged code.
/// </summary>
/// <param name="classid">
/// Class ID of the component
/// </param>
public void GetClassID(out System.Guid classid)
classid = new System.Guid("8bef7aa9-5da5-4d62-ac5b-03af2fb9d280");
/// <summary>
/// not implemented
/// </summary>
public void InitNew()
/// <summary>
/// Loads configuration properties for the component
/// </summary>
/// <param name="pb">Configuration property bag</param>
/// <param name="errlog">Error status</param>
public virtual void Load(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, int errlog)
/// <summary>
/// Saves the current component configuration into the property bag
/// </summary>
/// <param name="pb">Configuration property bag</param>
/// <param name="fClearDirty">not used</param>
/// <param name="fSaveAllProperties">not used</param>
public virtual void Save(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, bool fClearDirty, bool fSaveAllProperties)
#region utility functionality
/// <summary>
/// Reads property value from property bag
/// </summary>
/// <param name="pb">Property bag</param>
/// <param name="propName">Name of property</param>
/// <returns>Value of the property</returns>
private object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName)
object val = null;
try
pb.Read(propName, out val, 0);
catch (System.ArgumentException )
return val;
catch (System.Exception e)
throw new System.ApplicationException(e.Message);
return val;
/// <summary>
/// Writes property values into a property bag.
/// </summary>
/// <param name="pb">Property bag.</param>
/// <param name="propName">Name of property.</param>
/// <param name="val">Value of property.</param>
private void WritePropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName, object val)
try
pb.Write(propName, ref val);
catch (System.Exception e)
throw new System.ApplicationException(e.Message);
#endregion
#endregion
#region IComponentUI members
/// <summary>
/// Component icon to use in BizTalk Editor
/// </summary>
[Browsable(false)]
public IntPtr Icon
get
return ((System.Drawing.Bitmap)(this.resourceManager.GetObject("COMPONENTICON", System.Globalization.CultureInfo.InvariantCulture))).GetHicon();
/// <summary>
/// The Validate method is called by the BizTalk Editor during the build
/// of a BizTalk project.
/// </summary>
/// <param name="obj">An Object containing the configuration properties.</param>
/// <returns>The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator.</returns>
public System.Collections.IEnumerator Validate(object obj)
// example implementation:
// ArrayList errorList = new ArrayList();
// errorList.Add("This is a compiler error");
// return errorList.GetEnumerator();
return null;
#endregion
/// <summary>
/// this variable will contain any message generated by the Disassemble method
/// </summary>
private System.Collections.Queue _msgs = new System.Collections.Queue();
#region IDisassemblerComponent members
/// <summary>
/// called by the messaging engine until returned null, after disassemble has been called
/// </summary>
/// <param name="pc">the pipeline context</param>
/// <returns>an IBaseMessage instance representing the message created</returns>
public Microsoft.BizTalk.Message.Interop.IBaseMessage
GetNext(Microsoft.BizTalk.Component.Interop.IPipelineContext pc)
// get the next message from the Queue and return it
Microsoft.BizTalk.Message.Interop.IBaseMessage msg = null;
if ((_msgs.Count > 0))
msg = ((Microsoft.BizTalk.Message.Interop.IBaseMessage)(_msgs.Dequeue()));
return msg;
/// <summary>
/// called by the messaging engine when a new message arrives
/// </summary>
/// <param name="pc">the pipeline context</param>
/// <param name="inmsg">the actual message</param>
public void Disassemble(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
IBaseMessage Temp = inmsg;
using (ZipFile zip = ZipFile.Read(inmsg.BodyPart.GetOriginalDataStream()))
foreach (ZipEntry e in zip)
var ms = new MemoryStream();
IBaseMessage outMsg;
outMsg = pc.GetMessageFactory().CreateMessage();
outMsg.AddPart("Body", pc.GetMessageFactory().CreateMessagePart(), true);
outMsg.Context=inmsg.Context;
e.Extract(ms);
string XMLMessage = Encoding.UTF8.GetString(ms.ToArray());
MemoryStream mstemp = new System.IO.MemoryStream(
System.Text.Encoding.UTF8.GetBytes(XMLMessage));
outMsg.GetPart("Body").Data = mstemp;
_msgs.Enqueue(outMsg);
#endregion
Thanks
Abhishek -
Import/Export Large Complex XMl files(700MB) to MySQL tables
Am creating an application that will be mporting large and complex XML file in the range of 500-1000MB size. An xml ile wil have 5-6 levels of xml tags where the first tag will be the client account configuration e.g name, location, address, the second will be orders made, the third will be order items, fourth will be item defination...etc. The following is a sample structure of the file.
<mycompany_sales> <customer name="me"> <location country="Kenya"> <town>nairobi</toen> <order id="20000" date="2008-09-08"> <item id="4000"> <stock>2000</stock> <buying>300.0</buying> </item> ........ <total>5000</total> </order> .............. </location> </customer> ........... </mycompany_sales>
Because of the size, if i process this file using DOM it will result to out of memory error. I have tried parsing with SAX but it takes about 18 hours to process which is not ideal. If i import this data to Microsoft Access it takes about 10 minutes to import including it's relationship. i.e. creates the six tables and the foregin key relations.
I tried using XML-DBMS package but since it relies on DOM, it cant process. Does anyone know of a package that would help me import this data to any JDBC databse and also recreate the same structure of xml from the jdbc db. It would also be ideal if it can create sample map file during import and export.
Thanks in advance,
Simon K.kagara wrote:
I tried using XML-DBMS package but since it relies on DOM, it cant process. Does anyone know of a package that would help me import this data to any JDBC databse and also recreate the same structure of xml from the jdbc db. It would also be ideal if it can create sample map file during import and export.So you are parsing the XML, extracting the schema, using jdbc to create it, then parsing the data and using jdbc to populate it.
I suggest that you just create SQL directly. Or perhaps a import file if MySQL has it.
Less impact on the database, easier to test, easier to verify, and much faster to actually apply the data. -
Issue with reading a xml file from xsl
Hi,
When I am trying to read a xml file from xsl, I am getting unwanted output.
Following is the XSL:
<?xml version="1.0" encoding="UTF-8" ?>
<?oracle-xsl-mapper
<!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
<mapSources>
<source type="XSD">
<schema location="../xsd/B2BMarketProperties.xsd"/>
<rootElement name="ReceipentIDType" namespace="http://www.example.org"/>
</source>
</mapSources>
<mapTargets>
<target type="XSD">
<schema location="../xsd/B2BMarketProperties.xsd"/>
<rootElement name="ReceipentIDType" namespace="http://www.example.org"/>
</target>
</mapTargets>
<!-- GENERATED BY ORACLE XSL MAPPER 11.1.1.4.0(build 110106.1932.5682) AT [TUE DEC 03 16:06:03 EST 2013]. -->
?>
<xsl:stylesheet version="1.0"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://www.example.org"
xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:med="http://schemas.oracle.com/mediator/xpath"
xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
xmlns:bpm="http://xmlns.oracle.com/bpmn20/extensions"
xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ora="http://schemas.oracle.com/xpath/extension"
xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
exclude-result-prefixes="xsi xsl ns0 xsd bpws xp20 mhdr bpel oraext dvm hwf med ids bpm xdk xref ora socket ldap">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="ReceipentID" select="document('../xsd/B2BMarketProperties.xml')"/>
<xsl:template match="/">
<ns0:ReceipentIDType>
<xsl:for-each select="$ReceipentID">
<ns0:ReceipentID>
<xsl:value-of select="$ReceipentID"/>
</ns0:ReceipentID>
</xsl:for-each>
</ns0:ReceipentIDType>
</xsl:template>
</xsl:stylesheet>
Following is the XML ( B2BMarketProperties.xml)
<?xml version="1.0" encoding="UTF-8" ?>
<ReceipentIDType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org B2BMarketProperties.xsd"
xmlns="http://www.example.org">
<ReceipentID>123</ReceipentID>
<ReceipentID>345</ReceipentID>
</ReceipentIDType>
The output i am getting with this code is
<?xml version="1.0" encoding="UTF-8"?>
<ns0:ReceipentIDType xmlns:ns0="http://www.example.org">
<ns0:ReceipentID>123345</ns0:ReceipentID>
</ns0:ReceipentIDType>
But, I need output in the following format
<ns0:ReceipentIDType xmlns:ns0="http://www.example.org">
<ns0:ReceipentID>123</ns0:ReceipentID>
<ns0:ReceipentID>345</ns0:ReceipentID>
</ns0:ReceipentIDType>
Could you guys let me know what i am doing wrong. Any help would be appreciated.
Thanks,This worked for me :
<xsl:template match="/">
<ns0:ReceipentIDType>
<xsl:for-each select="document('B2BMarketProperties.xml')/*:ReceipentIDType/*:ReceipentID">
<xsl:variable name="count" select="position()"/>
<ns0:ReceipentID>
<xsl:value-of select="document('B2BMarketProperties.xml')/*:ReceipentIDType/*:ReceipentID[$count]"/>
</ns0:ReceipentID>
</xsl:for-each>
</ns0:ReceipentIDType>
</xsl:template> -
Hi Gurus,
I am dier need of one of the xml issue which I am facing right now.
I am reading one of the xml file which is like this
<?xml version="1.0" encoding="UTF-8" ?>
- <GEBIZ_ORDER xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <HEADER>
<MINISTRY_CODE>RPO</MINISTRY_CODE>
<DEPARTMENT_CODE>000</DEPARTMENT_CODE>
<ORDER_CODE>RPO000EPO11000953</ORDER_CODE>
<EXTERNAL_SYSTEM_CODE>E</EXTERNAL_SYSTEM_CODE>
<AMENDMENT_NUMBER>0</AMENDMENT_NUMBER>
<VARIATION_NUMBER>0</VARIATION_NUMBER>
<DESCRIPTION>Purchase Order for Air tickets for SOT to Korea (from 17th - 26th Sep 2011) off PC(RPO000ECN11000100)for SAS</DESCRIPTION>
<STATUS>NEW</STATUS>
<STATUS_DATE>2011-07-08T16:57:39</STATUS_DATE>
<PAYMENT_TERMS xsi:nil="true" />
<BILL_TO>One-Stop Centre, 9 Woodlands Avenue 9, S(738964)</BILL_TO>
<JUSTIFICATION>Please refer to attached approval email.</JUSTIFICATION>
<CREATE_TIMESTAMP>2011-07-08T16:57:39</CREATE_TIMESTAMP>
<TERMINATE_REASON xsi:nil="true" />
<TERMINATE_TIMESTAMP xsi:nil="true" />
<ORDER_TYPE>1</ORDER_TYPE>
- <FINANCIAL_SYSTEM>
<SUB_BUSINESS_UNIT>RPS01</SUB_BUSINESS_UNIT>
</FINANCIAL_SYSTEM>
- <SUPPLIER>
<CODE>200003048E</CODE>
<NAME>Safe2Travel Pte Ltd</NAME>
<GST_NUMBER>20-0003048-E</GST_NUMBER>
<CONTACT_NAME>ONG PEI LENG</CONTACT_NAME>
<CONTACT_PHONE>68233103</CONTACT_PHONE>
<CONTACT_EMAIL>[email protected]</CONTACT_EMAIL>
<CONTACT_FAX>68221636</CONTACT_FAX>
- <SITES>
- <SITE>
<ID>1</ID>
<NAME>ravel Pte Ltd</NAME>
<PHONE>68233013</PHONE>
<PHONE_EXTENSION xsi:nil="true" />
<FAX>68221636</FAX>
<EMAIL>[email protected]</EMAIL>
<ADDRESS_LINE1>10 Eunos Road 8</ADDRESS_LINE1>
<ADDRESS_LINE2>#08-03 (North Lobby)</ADDRESS_LINE2>
<ADDRESS_LINE3>Singapore Post Centre</ADDRESS_LINE3>
<COUNTRY_CODE>SG</COUNTRY_CODE>
<PROVINCE xsi:nil="true" />
<STATE xsi:nil="true" />
<CITY xsi:nil="true" />
<AREA_CODE xsi:nil="true" />
<ZIP>408600</ZIP>
<REGION_CODE xsi:nil="true" />
</SITE>
- <SITE>
<ID>2</ID>
<NAME>ravel Pte Ltd</NAME>
<PHONE>62208866</PHONE>
<PHONE_EXTENSION xsi:nil="true" />
<FAX>62265578</FAX>
<EMAIL>[email protected]</EMAIL>
<ADDRESS_LINE1>3 Lim Teck Kim Road</ADDRESS_LINE1>
<ADDRESS_LINE2>#02-02</ADDRESS_LINE2>
<ADDRESS_LINE3>Singapore Technologies Building</ADDRESS_LINE3>
<COUNTRY_CODE>SG</COUNTRY_CODE>
<PROVINCE xsi:nil="true" />
<STATE xsi:nil="true" />
<CITY xsi:nil="true" />
<AREA_CODE xsi:nil="true" />
<ZIP>088934</ZIP>
<REGION_CODE xsi:nil="true" />
</SITE>
- <SITE>
<ID>3</ID>
<NAME>Safe2Travel Pte Ltd</NAME>
<PHONE>62208866</PHONE>
<PHONE_EXTENSION xsi:nil="true" />
<FAX>62265578</FAX>
<EMAIL>[email protected]</EMAIL>
<ADDRESS_LINE1>3 Lim Teck Kim Road</ADDRESS_LINE1>
<ADDRESS_LINE2>#02-02</ADDRESS_LINE2>
<ADDRESS_LINE3>Singapore Technologies Building</ADDRESS_LINE3>
<COUNTRY_CODE>SG</COUNTRY_CODE>
<PROVINCE xsi:nil="true" />
<STATE xsi:nil="true" />
<CITY xsi:nil="true" />
<AREA_CODE xsi:nil="true" />
<ZIP>088934</ZIP>
<REGION_CODE xsi:nil="true" />
</SITE>
</SITES>
</SUPPLIER>
- <USER>
<CODE>JOYCE SOON</CODE>
<NAME>JOYCE SOON</NAME>
<ORGANISATION_NAME>Republic Polytechnic</ORGANISATION_NAME>
</USER>
- <FUND_COMMIT_AMOUNT>
<CURRENCY_CODE>SGD</CURRENCY_CODE>
<CURRENCY_RATE>1</CURRENCY_RATE>
<CURRENCY_RATE_DATE>1900-01-01T00:00:00</CURRENCY_RATE_DATE>
<CURRENCY_RATE_TYPE>BOOK</CURRENCY_RATE_TYPE>
<CURRENCY_AMOUNT>21551.4</CURRENCY_AMOUNT>
</FUND_COMMIT_AMOUNT>
- <PERIOD_CONTRACT>
<CODE>RPO000ECN11000100</CODE>
<AGENCY_CODE>RPO000</AGENCY_CODE>
<ADMIN_FEE_SGD_AMOUNT>0</ADMIN_FEE_SGD_AMOUNT>
</PERIOD_CONTRACT>
- <BUYER>
<ORGANISATION_CODE>1</ORGANISATION_CODE>
<ORGANISATION_NAME>Republic Polytechnic</ORGANISATION_NAME>
<NAME>Sally Ang</NAME>
<PHONE>31001711</PHONE>
<FAX>64151310</FAX>
<EMAIL>[email protected]</EMAIL>
</BUYER>
<APPROVING_OFFICERS />
</HEADER>
- <ITEMS>
- <ITEM>
<LINE_NUMBER>1</LINE_NUMBER>
<STATUS>NEW</STATUS>
<STATUS_DATE>2011-07-08T16:57:39</STATUS_DATE>
<DESCRIPTION>Return Air Ticket including Airport Taxes and Fuel Surcharges (2 staff and 24 students)</DESCRIPTION>
<UNIT_OF_MEASURE>PAX</UNIT_OF_MEASURE>
<QUANTITY>26</QUANTITY>
<LINE_TYPE>SERVICES</LINE_TYPE>
<UNIT_PRICE>828.9</UNIT_PRICE>
<PRICE_UNIT>1</PRICE_UNIT>
<TOTAL_AMOUNT>21551.4</TOTAL_AMOUNT>
<MATERIAL_MASTER_CODE xsi:nil="true" />
<MATERIAL_GROUP_CODE xsi:nil="true" />
<PLANT_CODE xsi:nil="true" />
<ITEM_CATEGORY_CODE xsi:nil="true" />
<ADMIN_FEE_SGD_AMOUNT>0</ADMIN_FEE_SGD_AMOUNT>
<INSTRUCTION_TO_SUPPLIER>Purchase of goods/services is subject to the Terms & Conditions found in www.rp.sg/purchase and/or in the ITQ/ITT Specifications. Please liaise with the Contact Person for delivery details. Invoice MUST be addressed to the Contact Person. PO number MUST be included in the Description field under e-Invoice Details section at Vendor@Gov.</INSTRUCTION_TO_SUPPLIER>
<PERIOD_CONTRACT_LINE_NUMBER>1</PERIOD_CONTRACT_LINE_NUMBER>
<GOODS_INSPECT_FLAG>N</GOODS_INSPECT_FLAG>
- <PURCHASE_REQUEST>
<CODE>RPO000EPR11000465</CODE>
<LINE_NUMBER>1</LINE_NUMBER>
</PURCHASE_REQUEST>
- <PART_NUMBER_INFORMATION>
<NATO_STOCK_NUMBER xsi:nil="true" />
<MANUFACTURER_PART_NUMBER xsi:nil="true" />
<PART_NUMBER xsi:nil="true" />
<CAGE_CODE xsi:nil="true" />
<CAGE_NAME xsi:nil="true" />
<ITEM_CONDITION xsi:nil="true" />
<MINIMUM_SHELF_LIFE xsi:nil="true" />
<SHELF_LIFE_REMAINING xsi:nil="true" />
<CERTIFICATE_OF_CONFORMANCE xsi:nil="true" />
<EXPORT_LICENSE xsi:nil="true" />
</PART_NUMBER_INFORMATION>
- <LOCATIONS>
- <LOCATION>
<LINE_NUMBER>1</LINE_NUMBER>
<STATUS>NEW</STATUS>
<STATUS_DATE>2011-07-08T16:57:39</STATUS_DATE>
<QUANTITY>26</QUANTITY>
<DELIVERY_DESTINATION>Republic Polytechnic, One-Stop Centre, 9 Woodlands Avenue 9, S(738964)</DELIVERY_DESTINATION>
<DELIVERY_DATE>2011-07-11T00:00:00</DELIVERY_DATE>
<DELIVERY_TERMS>LOC</DELIVERY_TERMS>
<PORT_OF_ORIGIN>-</PORT_OF_ORIGIN>
- <RECIPIENT>
<CODE>OSC</CODE>
<NAME>One Stop Centre</NAME>
<PHONE>65103000</PHONE>
<EMAIL>[email protected]</EMAIL>
</RECIPIENT>
- <DISTRIBUTIONS>
- <DISTRIBUTION>
<LINE_NUMBER>1</LINE_NUMBER>
<STATUS>NEW</STATUS>
<STATUS_DATE>2011-07-08T16:57:39</STATUS_DATE>
<QUANTITY>26</QUANTITY>
<CHART_OF_ACCOUNT>1/G01/3SAS/020/220908/0000/0000/0000</CHART_OF_ACCOUNT>
<PROJECT_DISTRIBUTION xsi:nil="true" />
</DISTRIBUTION>
</DISTRIBUTIONS>
</LOCATION>
</LOCATIONS>
</ITEM>
</ITEMS>
</GEBIZ_ORDER>I was able to read this kind of file structure but due to some constraints now they added supplier sites and increment that one which will be like variable kind of thing now.
And below mentioned is the script which I am using right now for reading that xml file
PROCEDURE XGBZPROD.XGBZ_PUR_ORD_XMLTAG_PROC(P_XML_FILE IN VARCHAR2, P_FOLDER_NAME IN VARCHAR2)
IS
lv_supp_file XMLTYPE;
lv_hdr_error VARCHAR2(240);
lv_line_error VARCHAR2(240);
lv_line_loc_err VARCHAR2(240);
lv_dist_err VARCHAR2(240);
l_file_name VARCHAR2(300);
l_folder_name VARCHAR2(300);
lv_sysdate DATE := sysdate;
BEGIN
l_file_name := p_xml_file;
l_folder_name := p_folder_name;
-- this clause to check whether is xml file or NODATA FILE.
IF upper(substr(l_file_name,instr(l_file_name,'.',1)+1,3)) ='XML' THEN
lv_supp_file := xmltype( bfilename('XMLDIR',P_XML_FILE), nls_charset_id('AL32UTF8'));
dbms_output.put_line('P_XML_FILE '||P_XML_FILE);
-- Initially insert data into 11g table
-- This is to read xml datafile
INSERT INTO XGBZ_PO_XML_DETAILS
(ministry_code ,
department_code ,
order_code ,
external_system_code ,
amendment_number ,
variation_number ,
description ,
status ,
status_date ,
payment_terms ,
bill_to ,
justification ,
create_timestamp ,
terminate_reason ,
terminate_timestamp ,
order_type ,
sub_business_unit ,
cost_center_group ,
buyer_code ,
financial_system_order_code ,
user_nric ,
supplier_code ,
supplier_name ,
gst_number ,
contact_name ,
contact_phone ,
contact_email ,
contact_fax ,
supp_site_id ,
supp_site_name ,
supp_site_phone ,
supp_sit_phone_ext ,
supp_site_fax ,
supp_site_email ,
supp_site_add_line1 ,
supp_site_add_line2 ,
supp_site_add_line3 ,
supp_site_country_code ,
supp_site_province ,
supp_site_state ,
supp_site_city ,
supp_site_area_code ,
supp_site_zip ,
supp_site_region_code ,
user_code ,
user_name ,
user_org_name ,
currency_code ,
currency_rate ,
currency_rate_date ,
currency_rate_type ,
currency_amount ,
tx_field_2 ,
agency_code ,
admin_fee_sgd ,
buyer_orgn_code ,
buyer_orgn_name ,
buyer_name ,
buyer_phone ,
buyer_fax ,
buyer_email ,
ao_code ,
ao_name ,
line_no ,
line_status ,
line_status_date ,
line_description ,
unit_of_measure ,
line_qty ,
line_type ,
unit_price ,
line_total_amount ,
material_master_code ,
material_group_code ,
item_category_code ,
line_admin_fee_sgd_amt ,
instruction_supplier ,
period_contract_line_no ,
goods_inspect_flag ,
pr_code ,
pr_line_number ,
nato_stock_number ,
manufacturer_part_no ,
part_number ,
cage_code ,
cage_name ,
item_condition ,
minimum_shelf_life ,
shelf_life_remaining ,
cert_of_conformance ,
export_license ,
line_location_no ,
line_loc_status ,
line_loc_status_date ,
line_loc_qty ,
delivery_destination ,
delivery_date ,
delivery_terms ,
port_of_origin ,
recipient_code ,
recipient_name ,
recipient_phone ,
recipient_email ,
dist_line_no ,
dist_line_status ,
dist_line_status_date ,
dist_line_qty ,
chart_of_account ,
project_distribution
SELECT --Header Data
ministry_code ,
department_code ,
order_code ,
external_system_code ,
amendment_number ,
variation_number ,
description ,
status ,
status_date ,
payment_terms ,
bill_to ,
justification ,
create_timestamp ,
terminate_reason ,
terminate_timestamp ,
order_type ,
sub_business_unit ,
cost_center_group ,
buyer_code ,
financial_system_order_code ,
user_nric ,
supplier_code ,
supplier_name ,
gst_number ,
contact_name ,
contact_phone ,
contact_email ,
contact_fax ,
supp_site_id ,
supp_site_name ,
supp_site_phone ,
supp_sit_phone_ext ,
supp_site_fax ,
supp_site_email ,
supp_site_add_line1 ,
supp_site_add_line2 ,
supp_site_add_line3 ,
supp_site_country_code ,
supp_site_province ,
supp_site_state ,
supp_site_city ,
supp_site_area_code ,
supp_site_zip ,
supp_site_region_code ,
user_code ,
user_name ,
user_org_name ,
currency_code ,
currency_rate ,
currency_rate_date ,
currency_rate_type ,
currency_amount ,
tx_field_2 ,
agency_code ,
admin_fee_sgd ,
buyer_orgn_code ,
buyer_orgn_name ,
buyer_name ,
buyer_phone ,
buyer_fax ,
buyer_email ,
ao_code ,
ao_name ,
line_no ,
line_status ,
line_status_date ,
line_description ,
unit_of_measure ,
line_qty ,
line_type ,
unit_price ,
line_total_amount ,
material_master_code ,
material_group_code ,
item_category_code ,
line_admin_fee_sgd_amt ,
instruction_supplier ,
period_contract_line_no ,
goods_inspect_flag ,
pr_code ,
pr_line_number ,
nato_stock_number ,
manufacturer_part_no ,
part_number ,
cage_code ,
cage_name ,
item_condition ,
minimum_shelf_life ,
shelf_life_remaining ,
cert_of_conformance ,
export_license ,
line_location_no ,
line_loc_status ,
line_loc_status_date ,
line_loc_qty ,
delivery_destination ,
delivery_date ,
delivery_terms ,
port_of_origin ,
recipient_code ,
recipient_name ,
recipient_phone ,
recipient_email ,
dist_line_no ,
dist_line_status ,
dist_line_status_date ,
dist_line_qty ,
chart_of_account ,
project_distribution
FROM XMLTable('/GEBIZ_ORDER'
passing lv_supp_file
columns
ministry_code VARCHAR2(3) path 'HEADER/MINISTRY_CODE',
department_code VARCHAR2(3) path 'HEADER/DEPARTMENT_CODE',
order_code VARCHAR2(17 ) path 'HEADER/ORDER_CODE',
external_system_code VARCHAR2(1) path 'HEADER/EXTERNAL_SYSTEM_CODE',
amendment_number VARCHAR2(5) path 'HEADER/AMENDMENT_NUMBER' ,
variation_number VARCHAR2(5) path 'HEADER/VARIATION_NUMBER',
description VARCHAR2(500) path 'HEADER/DESCRIPTION',
status VARCHAR2(500) path 'HEADER/STATUS',
status_date VARCHAR2(24) path 'HEADER/STATUS_DATE',
payment_terms VARCHAR2(400) path 'HEADER/PAYMENT_TERMS',
bill_to VARCHAR2(200) path 'HEADER/BILL_TO',
justification VARCHAR2(400) path 'HEADER/JUSTIFICATION',
create_timestamp VARCHAR2(24) path 'HEADER/CREATE_TIMESTAMP',
terminate_reason VARCHAR2(400) path 'HEADER/TERMINATE_REASON',
terminate_timestamp VARCHAR2(24) path 'HEADER/TERMINATE_TIMESTAMP',
order_type VARCHAR2(2 ) path 'HEADER/ORDER_TYPE',
sub_business_unit VARCHAR2(5 ) path 'HEADER/FINANCIAL_SYSTEM/SUB_BUSINESS_UNIT',
cost_center_group VARCHAR2(20 ) path 'HEADER/FINANCIAL_SYSTEM/NFS/COST_CENTER_GROUP',
buyer_code VARCHAR2(30 ) path 'HEADER/FINANCIAL_SYSTEM/NFS/BUYER_CODE',
financial_system_order_code VARCHAR2(20 ) path 'HEADER/FINANCIAL_SYSTEM/NFS/FINANCIAL_SYSTEM_ORDER_CODE',
user_nric VARCHAR2(9 ) path 'HEADER/FINANCIAL_SYSTEM/NFS/USER_NRIC',
supplier_code VARCHAR2(10) path 'HEADER/SUPPLIER/CODE',
supplier_name VARCHAR2(140) path 'HEADER/SUPPLIER/NAME' ,
gst_number VARCHAR2(30 ) path 'HEADER/SUPPLIER/GST_NUMBER',
contact_name VARCHAR2(140 ) path 'HEADER/SUPPLIER/CONTACT_NAME',
contact_phone VARCHAR2(23 ) path 'HEADER/SUPPLIER/CONTACT_PHONE',
contact_email VARCHAR2(100) path 'HEADER/SUPPLIER/CONTACT_EMAIL',
contact_fax VARCHAR2(23 ) path 'HEADER/SUPPLIER/CONTACT_FAX',
supp_site_id NUMBER path 'HEADER/SUPPLIER/SITES/SITE/ID',
supp_site_name VARCHAR2(140) path 'HEADER/SUPPLIER/SITES/SITE/NAME',
supp_site_phone VARCHAR2(23) path 'HEADER/SUPPLIER/SITES/SITE/PHONE',
supp_sit_phone_ext VARCHAR2(4 ) path 'HEADER/SUPPLIER/SITES/SITE/PHONE_EXTENSION',
supp_site_fax VARCHAR2(23 ) path 'HEADER/SUPPLIER/SITES/SITE/FAX',
supp_site_email VARCHAR2(100 ) path 'HEADER/SUPPLIER/SITES/SITE/EMAIL',
supp_site_add_line1 VARCHAR2(254 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE1',
supp_site_add_line2 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE2',
supp_site_add_line3 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE3',
supp_site_country_code VARCHAR2(2 ) path 'HEADER/SUPPLIER/SITES/SITE/COUNTRY_CODE',
supp_site_province VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/PROVINCE',
supp_site_state VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/STATE',
supp_site_city VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/CITY',
supp_site_area_code VARCHAR2(10 ) path 'HEADER/SUPPLIER/SITES/SITE/AREA_CODE',
supp_site_zip VARCHAR2(20 ) path 'HEADER/SUPPLIER/SITES/SITE/ZIP',
supp_site_region_code VARCHAR2(3 ) path 'HEADER/SUPPLIER/SITES/SITE/REGION_CODE',
user_code VARCHAR2(16 ) path 'HEADER/USER/CODE',
user_name VARCHAR2(25 ) path 'HEADER/USER/NAME',
user_org_name VARCHAR2(95 ) path 'HEADER/USER/ORGANISATION_NAME',
currency_code VARCHAR2(3 ) path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_CODE',
currency_rate NUMBER path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_RATE',
currency_rate_date VARCHAR2(24) path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_RATE_DATE',
currency_rate_type VARCHAR2(5 ) path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_RATE_TYPE',
currency_amount NUMBER path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_AMOUNT',
tx_field_2 VARCHAR2(17 ) path 'HEADER/PERIOD_CONTRACT/CODE',
agency_code VARCHAR2(6 ) path 'HEADER/PERIOD_CONTRACT/AGENCY_CODE',
admin_fee_sgd NUMBER path 'HEADER/PERIOD_CONTRACT/ADMIN_FEE_SGD_AMOUNT' ,
buyer_orgn_code VARCHAR2(5 ) path 'HEADER/BUYER/ORGANISATION_CODE',
buyer_orgn_name VARCHAR2(95 ) path 'HEADER/BUYER/ORGANISATION_NAME',
buyer_name VARCHAR2(80 ) path 'HEADER/BUYER/NAME',
buyer_phone VARCHAR2(23 ) path 'HEADER/BUYER/PHONE',
buyer_fax VARCHAR2(23 ) path 'HEADER/BUYER/FAX',
buyer_email VARCHAR2(100 ) path 'HEADER/BUYER/EMAIL',
ao_code VARCHAR2(16 ) path 'HEADER/APPROVING_OFFICERS/APPROVING_OFFICER/CODE',
ao_name VARCHAR2(40 ) path 'HEADER/APPROVING_OFFICERS/APPROVING_OFFICER/NAME',
items XMLTYPE path 'ITEMS'
) x1,
XMLTABLE('/ITEMS/ITEM'
passing x1.items
columns
line_no VARCHAR2(5) path 'LINE_NUMBER',
line_status VARCHAR2(15) path 'STATUS',
line_status_date VARCHAR2(24) path 'STATUS_DATE',
line_description VARCHAR2(500) path 'DESCRIPTION',
unit_of_measure VARCHAR2(3) path 'UNIT_OF_MEASURE',
line_qty NUMBER path 'QUANTITY',
line_type VARCHAR2(20) path 'LINE_TYPE',
unit_price NUMBER path 'UNIT_PRICE',
line_total_amount NUMBER path 'TOTAL_AMOUNT',
material_master_code VARCHAR2(20) path 'MATERIAL_MASTER_CODE',
material_group_code VARCHAR2(10) path 'MATERIAL_GROUP_CODE',
item_category_code VARCHAR2(18) path 'ITEM_CATEGORY_CODE',
line_admin_fee_sgd_amt NUMBER path 'ADMIN_FEE_SGD_AMOUNT',
instruction_supplier VARCHAR2(400) path 'INSTRUCTION_TO_SUPPLIER',
period_contract_line_no NUMBER path 'PERIOD_CONTRACT_LINE_NUMBER',
goods_inspect_flag VARCHAR2(1) path 'GOODS_INSPECT_FLAG',
pr_code VARCHAR2(17) path 'PURCHASE_REQUEST/CODE',
pr_line_number VARCHAR2(5) path 'PURCHASE_REQUEST/LINE_NUMBER',
nato_stock_number VARCHAR2(14) path 'PART_NUMBER_INFORMATION/NATO_STOCK_NUMBER',
manufacturer_part_no VARCHAR2(32) path 'PART_NUMBER_INFORMATION/MANUFACTURE_PART_NUMBER',
part_number VARCHAR2(200) path 'PART_NUMBER_INFORMATION/PART_NUMBER',
cage_code VARCHAR2(10) path 'PART_NUMBER_INFORMATION/CAGE_CODE',
cage_name VARCHAR2(140) path 'PART_NUMBER_INFORMATION/CAGE_NAME',
item_condition VARCHAR2(1) path 'PART_NUMBER_INFORMATION/ITEM_CONDITION' ,
minimum_shelf_life NUMBER path 'PART_NUMBER_INFORMATION/MINIMUM_SHELF_LIFE',
shelf_life_remaining VARCHAR2(3) path 'PART_NUMBER_INFORMATION/SHELF_LIFE_REMAINING',
cert_of_conformance VARCHAR2(1000) path 'PART_NUMBER_INFORMATION/CERTIFICATE_OF_CONFORMANCE',
export_license VARCHAR2(3) path 'PART_NUMBER_INFORMATION/EXPORT_LICENSE',
locations XMLTYPE path 'LOCATIONS'
)x2,
XMLTABLE('/LOCATIONS/LOCATION'
passing x2.locations
columns
line_location_no NUMBER path 'LINE_NUMBER',
line_loc_status VARCHAR2(15) path 'STATUS',
line_loc_status_date VARCHAR2(24) path 'STATUS_DATE',
line_loc_qty NUMBER path 'QUANTITY',
delivery_destination VARCHAR2(1000) path 'DELIVERY_DESTINATION',
delivery_date VARCHAR2(24) path 'DELIVERY_DATE',
delivery_terms VARCHAR2(3) path 'DELIVERY_TERMS',
port_of_origin VARCHAR2(150) path 'PORT_OF_ORIGIN',
recipient_code VARCHAR2(16 ) path 'RECIPIENT/CODE',
recipient_name VARCHAR2(40 ) path 'RECIPIENT/NAME',
recipient_phone VARCHAR2(23 ) path 'RECIPIENT/PHONE',
recipient_email VARCHAR2(100 ) path 'RECIPIENT/EMAIL',
distributions XMLTYPE path 'DISTRIBUTIONS'
)x3,
XMLTABLE('/DISTRIBUTIONS/DISTRIBUTION'
passing x3.distributions
columns
dist_line_no NUMBER path 'LINE_NUMBER',
dist_line_status VARCHAR2(15) path 'STATUS',
dist_line_status_date VARCHAR2(24) path 'STATUS_DATE',
dist_line_qty NUMBER path 'QUANTITY',
chart_of_account VARCHAR2(420) path 'CHART_OF_ACCOUNT',
project_distribution VARCHAR2(4000) path 'PROJECT_DISTRIBUTION'
)x4;
end;As there is change in requirement now I need to read the multiple supplier sites at the header level. Current this is my structure please give an idea how to read the mulitple sites as one record, probably i can increase the supplier site columns at table level so as to capture second site level information.
But if in case if i receive that time it should not fail please provide some good solution for this issue.
Thanks in advance for your help.
Regards
NagendraHi odie,
Thanks for your response. But here my supplier site will always be maxiumum 2 times and minimum 1 time. My thinking is to fit this one in the existing code by repeating the supplier site only like this
supp_site_id NUMBER path 'HEADER/SUPPLIER/SITES/SITE/ID',
supp_site_name VARCHAR2(140) path 'HEADER/SUPPLIER/SITES/SITE/NAME',
supp_site_phone VARCHAR2(23) path 'HEADER/SUPPLIER/SITES/SITE/PHONE',
supp_sit_phone_ext VARCHAR2(4 ) path 'HEADER/SUPPLIER/SITES/SITE/PHONE_EXTENSION',
supp_site_fax VARCHAR2(23 ) path 'HEADER/SUPPLIER/SITES/SITE/FAX',
supp_site_email VARCHAR2(100 ) path 'HEADER/SUPPLIER/SITES/SITE/EMAIL',
supp_site_add_line1 VARCHAR2(254 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE1',
supp_site_add_line2 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE2',
supp_site_add_line3 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE3',
supp_site_country_code VARCHAR2(2 ) path 'HEADER/SUPPLIER/SITES/SITE/COUNTRY_CODE',
supp_site_province VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/PROVINCE',
supp_site_state VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/STATE',
supp_site_city VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/CITY',
supp_site_area_code VARCHAR2(10 ) path 'HEADER/SUPPLIER/SITES/SITE/AREA_CODE',
supp_site_zip VARCHAR2(20 ) path 'HEADER/SUPPLIER/SITES/SITE/ZIP',
supp_site_region_code VARCHAR2(3 ) path 'HEADER/SUPPLIER/SITES/SITE/REGION_CODE',
supp_site_id2 NUMBER path 'HEADER/SUPPLIER/SITES/SITE/ID',
supp_site_name2 VARCHAR2(140) path 'HEADER/SUPPLIER/SITES/SITE/NAME',
supp_site_phone2 VARCHAR2(23) path 'HEADER/SUPPLIER/SITES/SITE/PHONE',
supp_sit_phone_ext2 VARCHAR2(4 ) path 'HEADER/SUPPLIER/SITES/SITE/PHONE_EXTENSION',
supp_site_fax2 VARCHAR2(23 ) path 'HEADER/SUPPLIER/SITES/SITE/FAX',
supp_site_email2 VARCHAR2(100 ) path 'HEADER/SUPPLIER/SITES/SITE/EMAIL',
supp_site_add_line1_2 VARCHAR2(254 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE1',
supp_site_add_line2_2 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE2',
supp_site_add_line3_2 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE3',
supp_site_country_code_2 VARCHAR2(2 ) path 'HEADER/SUPPLIER/SITES/SITE/COUNTRY_CODE',
supp_site_province_2 VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/PROVINCE',
supp_site_state_2 VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/STATE',
supp_site_city_2 VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/CITY',
supp_site_area_code_2 VARCHAR2(10 ) path 'HEADER/SUPPLIER/SITES/SITE/AREA_CODE',
supp_site_zip_2 VARCHAR2(20 ) path 'HEADER/SUPPLIER/SITES/SITE/ZIP',
supp_site_region_code_2 VARCHAR2(3 ) path 'HEADER/SUPPLIER/SITES/SITE/REGION_CODE',As this table I am being used in many areas, it will be problem for me if try to go for different levels of tables. Or else can it be possible to read only once
I mean only the first in the xml tags and leave the second xml. As there is not much significant for the second one.
I appreciate your ideas on this, as the structure we are following is to rigid so I don't have much options to explore, please provide me your inputs in this context.
Thanks for your help.
Regards
Nagendra
Edited by: 838961 on Jul 13, 2011 1:43 AM -
Reading A xml file and sending that XML Data as input to a Service
Hi All,
I have a requirement to read(I am using File adapter to read) a xml file and map the data in that xml to a service(schema) input variable.
Example of xml file that I have to read and the content of that xml file like below:
<StudentList>
<student>
<Name> ravi</Name>
<branch>EEE</branch>
<fathername> raghu</fathername>
</student>
<student>
<Name> raju</Name>
<branch>ECE</branch>
<fathername> ravi</fathername>
</student>
<StudentList>
I have to pass the data(ravi,EEE,raghu etc) to a service input varible. That invoked Service input variable(schema) contains the schema similar to above schema.
My flow is like below:
ReadFile file adapter -------------------> BPEL process -----> Target Service.I am using transform activity in BPEL process to map the data from xml file to Service.
I am using above xml file as sample in Native Data format(to create XSD schema file).
After I built the process,I checked file adapter polls the data and receive the file(I am getting View xml document in EM console flow).
But transform activity does not have anything and it is not mapping the data.I am getting blank data in the transform activity with only element names like below
---------------------------------------------------------------------------EM console Audit trail (I am giving this because u can clearly understand what is happening-----------------------------------------------------
-ReceiveFile
-some datedetails received file
View XML document (This xml contains data and structure like above xml )
- transformData:
<payload>
<InvokeService_inputvariable>
<part name="body">
<StudentList>
<student>
<name/>
<branch/>
<fathername/>
</student>
</StudentList>
</part>
</InvokeService_inputvariable>
'Why I am getting like this".Is there any problem with native data format configuration.?
Please help me out regarding this issue as I am running out my time.Hi syam,
Thank you very much for your replies so far so that I have some progrees in my task.
As you told I could have put default directory in composite.xml,but what happenes is the everyday new final subdirectory gets created in the 'soafolder' folder.What I mean is in the c:/soafolder/1234_xmlfiles folder, the '1234_xmlfiles' is not manually created one.It is created automatically by executing some jar.
Basically we can't know the sub folder name until it is created by jar with its own logic. whereas main folder is same(soafolder) ever.
I will give you example with our folder name so that it would be more convenient for us to understand.
1) yesterday's the folder structure : 'c:/soafolder/130731_LS' .The '130731_LS' folder is created automatically by executing some jar file(it has its own logic to control and create the subdirectories which is not in our control).
2) Today's folder structure : 'c:/soafolder/130804_LS. The folder is created automatically(everytime the number part(130731,130804).I think that number is indicating 2013 july 31 st like that.I have to enquire about this)is changing) at a particular time and xml files will be loaded in the folder.
Our challenge : It is not that we can put the default or further path in composite.xml and poll the file adapter.Not everytime we have to change the path in composite.xml.The process should know the folder path (I don't know whether it is possible or not.) and everyday and file adapter poll the files in that created subfolders.
I hope you can understand my requirement .Please help me out in this regard. -
Reading a XML file in a standalone java application
Hi,
What are my options if I have a standalone java application running outside any app. server and I need to read an XML file, probably read some of the attributes in the file...? Please explain clearly as I'm new to this. Appreciate your help.
Thanks,
Mahdadnope you don't need a DTD
you have to write your Java code in a way that doesn't rely too much on the structure:
- avoid getFirstChild().getFirstChild()... because you know that this element is first grandson of that element)
- prefer using getElementByTagName() or some XPath() API
but if the XML completely changes, well, yeah, you have to do some programmation: better think well your document structure in the beginning. -
Hi,
I have the code below to read a xml file into a DOM, as a standalone class it works fine, but now I want to have this class as a bean, and I don't know how to get the xml file path. I'm using JBoss.
package meuPacote;
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public class LerConstantes {
public void leConstantes() {
Document doc = parseXmlFile("infilename", false);
System.out.println("doc " + doc);
Element element = doc.getElementById("primeira");
String primeira ="";
if(element != null) primeira = doc.getElementById("primeira").hasAttribute("valorConstante")?element.getAttribute("valorConstante"):"";
System.out.println("valor -->" + primeira);
// public static void main(String[] args) {
// Document doc = parseXmlFile("infilename.xml", false);
// Element element = doc.getElementById("primeira");
// String primeira ="";
// if(element != null) primeira = doc.getElementById("primeira").hasAttribute("valorConstante")?element.getAttribute("valorConstante"):"";
// System.out.println("valor -->" + primeira);
// Parses an XML file and returns a DOM document.
// If validating is true, the contents is validated against the DTD
// specified in the file.
public static Document parseXmlFile(String filename, boolean validating) {
try {
// Create a builder factory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(validating);
// Create the builder and parse the file
Document doc = factory.newDocumentBuilder().parse(new File(filename));
return doc;
} catch (SAXException e) {
// A parsing error occurred; the xml input is not valid
} catch (ParserConfigurationException e) {
} catch (IOException e) {
return null;
}thanks, VJignesh,
This is an XQuery forum. XDK has an XSU (XML SQL Utility) component that may help here. You can post your question to the XDK forum.
Regards,
Geoff -
When I am reading an XML file in a folder I am getting extra characters like squares before and after each and every character of the XML file.
Why is this so.I thought they are spaces and trimmed it but i didnt work.I replaced thinking as escape characters and that also did not work.But when I am prionting the ASCII value of the first character of the file I am getting -17.
Please can anyone help me out of this.
Thanks,
Sravanthipublic class Example()
File file = new File("C:/SCTMUnZip/"+files);
System.out.println("Files inside the directory:::"+files[i]);
String filedata = getContentsofFile(file);
if(file.getName().contains(".xml"))
InputStreamReader reader = new InputStreamReader(new FileInputStream("C:/SCTMUnZip/"+files[i]+"/"));
System.out.println("Encoding Style:::"+reader.getEncoding());
byte[] filebytes = filedata.getBytes("UTF-16");//byte[] utf8String = Encoding.UTF8.GetBytes(srcString);
System.out.println("This is a XML File...");
file1.setMStrFileName(files[i]);
file1.setMPFileData(filebytes);
//file1.setMStrFileName(files[i]);
/*Pattern pattern = Pattern.compile("[^]");
Matcher matcher = pattern.matcher(filedata);
String str = matcher.replaceAll("");
filedata = str;
System.out.print(str);*/
else
System.out.println("This is a normal file...");
file1.setMStrFileName(files[i]);
file1.setMPFileData(filedata.getBytes());
static public String getContentsofFile(File file)
StringBuilder filecontents = new StringBuilder();
try
BufferedReader input = new BufferedReader(new FileReader(file));
try
String line = null; //not declared within while loop
* readLine is a bit quirky :
* it returns the content of a line MINUS the newline.
* it returns null only for the END of the stream.
* it returns an empty String if two newlines appear in a row.
while (( line = input.readLine()) != null){
filecontents.append(line);
filecontents.append(System.getProperty("line.separator"));
finally {
input.close();
catch (IOException ex){
ex.printStackTrace();
return filecontents.toString();
The files in the folder are log.txt and output.xml(has UTF-16 as the encoding style in the first line).log.txt is read fine but output.xml is not. -
I need for a simple example of reading a xml file using jdom
Hello
I have been looking for a simple example that uses Jdom to read am xml file and use the information for anything( ), and I just can't find one.since I'm just beggining to understand how things work, I need a good example.thanks
here is just a simple cod for example:
<xmlMy>
<table>
<item name="first" value="123" createdDate="1/1/90"/>
<item name="second" value="456" createdDate="1/4/96"/>
</table>
<server>
<property name="port" value="12345"/>
<property name="maxClients" value="3"/>
</server>
</xmlMy>DaveHi,
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream("my_xml_file.xml");
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally{
if (fileInputStream == null) return;
SAXBuilder saxBuilder = new SAXBuilder();
saxBuilder.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
return new InputSource(new StringReader(""));
Document document = null;
try {
document = saxBuilder.build(fileInputStream);
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (document == null) return;
Element element = document.getRootElement();
System.out.println(element.getName());
System.out.println(element.getChild("table").getName());
Maybe you are looking for
-
HashSet get() and contains() methods, by value or reference?
All the tutorials I've seen on HashSets use Strings as the object type. With Strings, it seems the get() and contains() methods work by value, not by reference. <CODE> String s1 = "dog"; String s2 = "cat"; String s3 = "dog"; HashSet<String> set = new
-
Why can't I read Japanese characters on song titles and artists on my itunes
For some reason all of my Japanese songs titles and artists are in this random jumbled text, and I was wondering if anyone can help me fix it.
-
Swf plays in Windows browsers, but not in Mac ones
I'm trying to create a simple swf file containing an m4v file along with default player controls. I want to add this to a Web page. I've successfully generated such a file, and using the HTML generated by the publish option, I've gotten it to play on
-
Using eMac keyboard with iMac help needed.
I have an iMac from around 2009, at the weekend the keyboard stopped working and until I can afford a replacement a friend has given me an old eMac keyboard he had spare to use in the meantime (which could be a while). Just this morning I've realised
-
Documenting command line arguments
I'm very new to javadoc, and I'm trying to put together a set of guidelines for our developers to follow. One thing I came accross was command line arguments. If a main function is expecting command line arguments, how would this be documented, shoul