Xml attribute value
I'm having trouble getting a specific attribute value when
parsing the xml tree. I need to get the chidNode that matches
my attribute
request. Is there an easy way to say if the attribute value =
1234 then return
its nodevalue
myXML = new XML();
myXML.load("sample.xml");
myXML.ignoreWhite = true;
myXML.onLoad=feeds;
function feeds(){
myroot = myXML.firstChild;
people = myroot.firstChild;
students = people.childNodes;
if(students.attributes.id == '1234')
trace('yes record found')
the xml at the students level lookss like this
<student id="2214">
<name></name>
</student>
<student id="1234">
<name></name>
</student>
<student id="4567">
<name></name>
</student>
thanks
Well, assuming there is an associated end tag (aka </TEST>) somewhere in your XML, then the XML fragment you show is well-formed XML.
If by "XML functions", you mean something like XMLElement/XMLForest/XMLAgg, then you can be safe to know that it generates well-formed XML.
What is this "xml editor" that you mention but don't name. It sounds as if the issue lies with that tool, based off what little you have provided.
The more details you provide, the better answer you get.
Similar Messages
-
How to remove the XML attribute value in Indesign file by javascript
Hi all,
How to remove the XML attribute value in Indesign file.Try this,
if(elm.xmlElements[i].xmlAttributes[j].name == "aid:pstyle" || elm.xmlElements[i].xmlAttributes[j].name == "aid:cstyle")
Vandy -
Extract XML attribute value for multi-item sequence
Guys,
I have already posted this in the XML DB forum, but am relying that some of you might help me.
I have been searching for a solution for this and couldn't quite get it. I'm trying to get attribute values from multiple entries in a Node. It workes for a single node, but for multiple nodes, it fails. Could you please give me a solution?
SQL> select extractvalue(column_value, '/WORLD/COUNTRY/@NAME') COUNTRY_NAME
2 ,extractvalue(column_value, '/WORLD/COUNTRY/CITY/@NAME') CITY_NAME
3 ,extractvalue(column_value, '/WORLD/COUNTRY/CITY/@POPULATION') POPULATION
4 from xmltable('WORLD' passing xmltype('
5 <WORLD>
6 <COUNTRY NAME="INDIA">
7 <CITY NAME="MUMBAI" POPULATION="10000"></CITY>
8 </COUNTRY>
9 </WORLD>'
10 ));
COUNTRY_NAME CITY_NAME POPULATION
INDIA MUMBAI 10000When I execute the same for multiple nodes, it fails, please guide me. Please also let me know how to handle if I have an XML file containing this data.
SQL> select extractvalue(column_value, '/WORLD/COUNTRY/@NAME') COUNTRY_NAME
2 ,extractvalue(column_value, '/WORLD/COUNTRY/CITY/@NAME') CITY_NAME
3 ,extractvalue(column_value, '/WORLD/COUNTRY/CITY/@POPULATION') POPULATION
4 from xmltable('WORLD' passing xmltype('
5 <WORLD>
6 <COUNTRY NAME="INDIA">
7 <CITY NAME="MUMBAI" POPULATION="10000"></CITY>
8 <CITY NAME="CHENNAI" POPULATION="2000"></CITY>
9 <CITY NAME="BANGALORE" POPULATION="13000"></CITY>
10 <CITY NAME="HYDERABAD" POPULATION="14000"></CITY>
11 </COUNTRY>
12 </WORLD>'
13 ));
select extractvalue(column_value, '/WORLD/COUNTRY/@NAME') COUNTRY_NAME
ERROR at line 1:
ORA-19025: EXTRACTVALUE returns value of only one nodeCheers
Sarma.So, this is the first step:
SQL> with test as
2 (select xmltype('<WORLD>
3 <COUNTRY NAME="INDIA">
4 <CITY NAME="MUMBAI" POPULATION="10000"></CITY>
5 <CITY NAME="CHENNAI" POPULATION="2000"></CITY>
6 <CITY NAME="BANGALORE" POPULATION="13000"></CITY>
7 <CITY NAME="HYDERABAD" POPULATION="14000"></CITY>
8 </COUNTRY>
9 </WORLD>') resp from dual)
10 select country
11 , cities
12 from xmltable('WORLD/COUNTRY' passing (select resp from test)
13 columns country varchar2(50) path '/COUNTRY/@NAME'
14 , cities xmltype path '/COUNTRY/CITY') world
15 /
COUNTRY CITIES
INDIA <CITY NAME="MUMBAI" POPULATION="10000"/><CITY NAME
="CHENNAI" POPULATION="2000"/><CITY NAME="BANGALOR
E" POPULATION="13000"/><CITY NAME="HYDERABAD" POPU
LATION="14000"/>two columns, one varchar2 and one xmltype.
Then do the same thing with the second column, pass the XML to an XMLTABLE function
SQL> with test as
2 (select xmltype('<WORLD>
3 <COUNTRY NAME="INDIA">
4 <CITY NAME="MUMBAI" POPULATION="10000"></CITY>
5 <CITY NAME="CHENNAI" POPULATION="2000"></CITY>
6 <CITY NAME="BANGALORE" POPULATION="13000"></CITY>
7 <CITY NAME="HYDERABAD" POPULATION="14000"></CITY>
8 </COUNTRY>
9 </WORLD>') resp from dual)
10 select country
11 , cit.name
12 , cit.population
13 from xmltable('WORLD/COUNTRY' passing (select resp from test)
14 columns country varchar2(50) path '/COUNTRY/@NAME'
15 , cities xmltype path '/COUNTRY/CITY') world
16 , xmltable ('CITY' passing cities
17 columns name varchar2(50) path '@NAME'
18 , population number path '@POPULATION'
19 ) cit
20 ;
COUNTRY NAME POPULATION
INDIA MUMBAI 10000
INDIA CHENNAI 2000
INDIA BANGALORE 13000
INDIA HYDERABAD 14000 -
InDesign CS3 crash during document open (at XML Attribute Value update for locked item)
OS: Windows XP
InDesign: InDesign Release 5.0.0.458
Plugins: No additional plugins
I am facing crash in InDesign at following workflow
Steps:
1. Create a new document.
2. Create a graphic frame.
3. Place an Image (C:\TESTDIR\images\test-image.jpg)
4. Tag the graphic frame (Right Click -> Autotag).
5. Lock the layer.
6. Save the doc at (C:\TESTDIR\files\test-doc.indd).
7. Move the image file to (C:\TESTDIR\)
8. Open the same document.
9. InDesign Crash.
Crash log:
Adobe InDesign Protective Shutdown Log
06/01/09 14:48:51
Unhandled error condition
Session started up at 2:44 PM on Monday, June 01, 2009
Version: 5.0.0 - Build: 458
Error Code 0xbfcd: "Cannot modify elements that contain locked content, or are contained by locked content. Please unlock or check out the content and try again."
Command Sequence:
> kOpenFileWithWindowCmdBoss = ""
> kOpenFileCmdBoss = ""
> kOpenDocCmdBoss = ""
> kSetDocNameCmdBoss = ""
> kSetDocNameCmdBoss = ""
> kSetAllUsedStyleCmdBoss = ""
> kSetAllUsedStyleCmdBoss = ""
> kRestoreLinkCmdBoss = "Restore Link" : kBeforeDoMessageBoss @ kDocBoss (IID_ICOMMANDMGR)
> kSetAssetAttributesCmdBoss = "" : kBeforeDoMessageBoss @ kDocBoss (IID_ICOMMANDMGR)
> kSetAssetAttributesCmdBoss = "" : kAfterDoMessageBoss @ kDocBoss (IID_ICOMMANDMGR)
> kXMLSetAttributeValueCmdBoss = "Set Attribute Value" : kBeforeDoMessageBoss @ kDocBoss (IID_ICOMMANDMGR)
> kXMLSetAttributeValueCmdBoss = "Set Attribute Value" : kAfterDoMessageBoss @ kDocBoss (IID_ICOMMANDMGR)
> kRestoreLinkCmdBoss = "Restore Link" : kAfterDoMessageBoss @ kDocBoss (IID_ICOMMANDMGR)
Please let me know how to stop XML tag updation (execution of kXMLSetAttributeValueCmdBoss) at document open.Is the first time one of these files crashes always on one system or another, or is it random across systems?
It is random and it's not related to a file (one time i can open the file andanother time it cause an InDesign crash);
It sounds very much like a font problem. Are you using a font manager, and if so, which one?
We have reproduced the problem also on machine with only system's fonts.
I forgot to say that the crashes happen only with InDesign files with InCopy files linked in.
Thanks
Alessandro -
How to Get xml Attribute value from a given xpath
i'm building an xml from 3 columns a,b,c using 'SELECT EXTRACT (XMLELEMENT ("ROOT",.........)'
and my xml looks something like this
<ROOT>
<categories>
<catogory value="col a value" display="true"/>
<catogory value="col b value" display="false"/>
<catogory value="col c value" display="false"/>
</categories>
<DATAS>
</DATA>
</ROOT>
now under the datas node i want to use xpath like this
(case when '/root/categories/catogory/[@display="true"]' then '/root/categories/catogory/@value' else 0 end)
so tat i get values under data node based on display attributes.... is it possible..
if not is ther any alternative way of using xpathWhat version of Oracle (4 digits)?
Are you trying to populate the Data node when you are building the XML originally via your SQL/XML statement or are you talking about modifying some existing XML to add more nodes to it based on data in the XML already? -
Trying to assign an XML attribute value to a button label
I have a Flex app (developed in FLEX 2) that reads from
multiple XML files and populates datagrids with element values.
What I'm trying to do now, is to create a second column with a
button, enabling users to view archived versions for each current
report.
My problem is: I can't get the <mx:Button> label to
accept the attribute "name". I've tried atleast 10 - 20 different
syntax.
My XML file looks like this:
<metrics>
<report name="test">
<link>test Report 10/28/2008</link>
<url>test-10_28_2008.zip</url>
<status>active</status>
</report>
</metrics>
The mxml looks like this:
<mx:Button buttonMode="true" useHandCursor="true"
click="handleClick()" label="{data.@name}" width="80">
<mx:Script>
<![CDATA[
public function handleClick():void{
var url:URLRequest = new
URLRequest([L=http://new.test.com/pages/r_archive_apps/"+data.link+".html");[/L]]http://n ew.test.com/pages/r_archive_apps/"+data.link+".html");[/L][/L]
navigateToURL(url,"_blank");
]]>
</mx:Script>
</mx:Button>
When I try to label a button with an element it works fine.
Some of the other sytax I've used are:
- label="{data.report.@name}"
- label="{data.report.(@name=='test')}"
- label="{data.report.(@name='test')}"
- label="{data.@name}"
- label="{data.metrics.report.@name}"
- label="{data.metrics.report.(@name=='test')}"
- label="{data.metrics.report.(@name='test')}"quote:
Originally posted by:
rtalton
Can you post some code so we can see how you are using the
button? I think you may be using the button within a datagrid
itemRenderer, which might make a difference.
You're right, the button is in a datagrid itemRenderer. I've
pasted more dataGrid code below - thanks again.
<mx:DataGrid id="dgCatalog" dataProvider="{_xlcCatalog}"
rowCount="4" editable="false" sortableColumns="false"
left="148" top="65" bottom="42" borderStyle="solid"
alternatingItemColors="[#ecf8ff, #ffffff]"
themeColor="#ffff80" alpha="1.0" cornerRadius="0"
dropShadowEnabled="true" dropShadowColor="#000000" width="549"
creationCompleteEffect="{glow3}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn editable="false" headerText="Daily -
Report Names" dataField="link" textAlign="left" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:LinkButton click="handleClick()" label="{data.link}"
>
<mx:Script>
<![CDATA[
public function handleClick():void{
var url:URLRequest = new URLRequest("
http://test.new.com/test/"+data.url);
navigateToURL(url,"_blank");
]]>
</mx:Script>
</mx:LinkButton>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn editable="false" headerText="Daily -
Report Archives" dataField="link" textAlign="left" width="80">
<mx:itemRenderer>
<mx:Component>
<mx:Button buttonMode="true" useHandCursor="true"
click="handleClick()" label="{data.report.@name}" width="80">
<mx:Script>
<![CDATA[
public function handleClick():void{
var url:URLRequest = new URLRequest("
http://test.new.com/pages/test_apps/"+data.link+".html");
navigateToURL(url,"_blank");
]]>
</mx:Script>
</mx:Button>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<!--mx:DataGridColumn headerText="URL" dataField="url"
width="350"/>
<mx:DataGridColumn headerText="Status" dataField="status"
width="70"/-->
</mx:Array>
</mx:columns>
</mx:DataGrid> -
Retrieve xml attribute value of nth xml node using xpath query
I have an xml with following stucture...
<xml>
<header>
<DocumentReference OrderId="order001">
<DocumentReference OrderId="order002">
<DocumentReference OrderId="order003">
I have to loop through this xml and retrieve the orderId values inside Biztalk orchestration.
In the expression shape, I get the count of 'DocumentReference' nodes using an xpath query and then
Added a loopshape to make sure it loops thru all nodes
Loop condition: n<=nodeCount (where n is an integer variable, n=0 to begin with, incremented by 1 thru each loop, nodeCount is # of DocumentReference nodes)
I try retrieve to the orderId in the following expression shape using the below xpath query
xpathQuery = System.String.Format("//*[local-name()='OrderReference'][{0}]/@orderID)",n);
sOrderId = xpath(MsgSingleInvoice,xpathQuery);
And I get the following exception:
Inner exception: '//*[local-name()='OrderReference'][1]/@orderID)' has an invalid token.
Exception type: XPathException
Appreciate any help! thanks!Thanks for the quick response. I got rid of it.
And I see a different error:
Inner exception: Specified cast is not valid. Exception type: InvalidCastException
Source: Microsoft.XLANGs.Engine
Target Site: System.Object XPathLoad(Microsoft.XLANGs.Core.Part, System.String, System.Type)
Since variable 'n' is of integer type, I suspected it and changed it to n.ToString() and tested again and still see the same error. -
Hi all,
i'm new to flex.I have a problem regarding XML
attributes."How to get the XML attribute value from the xml file to
Flex application using HTTPService".I tried but it is coming only
one attribute value.
First i have to get the attribute values from the XML file
and display in AdvancedDataGrid with tree structure.
Here i will send my XML file and MXML file...
Can u see and check my code............plzzz
XML file................
<?xml version="1.0" encoding="UTF-8"?>
<todolist>
<folder state="" label="Today todo list" isBranch="true"
>
<folder cat="Travel" state="High" duedate="3/09/2008"
isBranch="false" label="book tickets" />
<folder cat="Social" state="Low" duedate="4/09/2008"
isBranch="false" label="Meeting at 7pm" />
<folder state="" isBranch="true" label="Home " >
<folder cat="Home" state="High" duedate="3/09/2008"
isBranch="false" label="Pay power bill" />
<folder cat="Home" state="High" duedate="3/09/2008"
isBranch="false" label="Pay rent" />
<folder cat="Home" state="Low" duedate="3/09/2008"
isBranch="false" label="Call parents" />
<folder cat="Home" state="Low" duedate="3/09/2008"
isBranch="false" label="Attend John birthday party" />
<folder cat="Home" state="Medium" duedate="3/09/2008"
isBranch="false" label="Special Updates" />
<folder cat="Home" state="high" isBranch="false"
label="get Dr. appointment" />
</folder>
<folder state="" isBranch="true" label="Office " >
<folder cat="Off" state="High" isBranch="false"
label="Meeting at 5pm" />
<folder cat="Off" state="Low" isBranch="false"
label="Complete document and send to client" />
<folder cat="Off" state="Low" isBranch="false"
label="Interviews and Transcripts" />
<folder cat="Off" state="High" isBranch="false"
label="Set Deployment machine" />
<folder cat="Off" state="High" isBranch="false"
label="send status reports" />
</folder>
</folder>
</todolist>
MXML file............
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute"
initialize="adgService.send()">
<mx:HTTPService id="adgService" url="adg.xml"/>
<mx:AdvancedDataGrid
dataProvider="{adgService.lastResult.todolist.folder}">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Name"
dataField="label"/>
<mx:AdvancedDataGridColumn headerText="Age"
dataField="state"/>
</mx:columns>
</mx:AdvancedDataGrid>
</mx:Application>
Thnaks & Regards
edeewan"edeewan" <[email protected]> wrote in
message
news:[email protected]...
> Hi all,
> i'm new to flex.I have a problem regarding XML
attributes."How to
> get
> the XML attribute value from the xml file to Flex
application using
> HTTPService".I tried but it is coming only one attribute
value.
>
> First i have to get the attribute values from the XML
file and display in
> AdvancedDataGrid with tree structure.
> Here i will send my XML file and MXML file...
> Can u see and check my code............plzzz
>
> XML file................
>
> <?xml version="1.0" encoding="UTF-8"?>
> <todolist>
> <folder state="" label="Today todo list"
isBranch="true" >
>
> <folder cat="Travel" state="High" duedate="3/09/2008"
isBranch="false"
> label="book tickets" />
> <folder cat="Social" state="Low" duedate="4/09/2008"
isBranch="false"
> label="Meeting at 7pm" />
>
> <folder state="" isBranch="true" label="Home " >
>
> <folder cat="Home" state="High" duedate="3/09/2008"
isBranch="false"
> label="Pay power bill" />
> <folder cat="Home" state="High" duedate="3/09/2008"
isBranch="false"
> label="Pay rent" />
> <folder cat="Home" state="Low" duedate="3/09/2008"
isBranch="false"
> label="Call parents" />
> <folder cat="Home" state="Low" duedate="3/09/2008"
isBranch="false"
> label="Attend John birthday party" />
> <folder cat="Home" state="Medium" duedate="3/09/2008"
> isBranch="false"
> label="Special Updates" />
> <folder cat="Home" state="high" isBranch="false"
label="get Dr.
> appointment" />
>
> </folder>
>
> <folder state="" isBranch="true" label="Office " >
>
> <folder cat="Off" state="High" isBranch="false"
label="Meeting
> at
> 5pm" />
> <folder cat="Off" state="Low" isBranch="false"
label="Complete
> document and send to client" />
> <folder cat="Off" state="Low" isBranch="false"
> label="Interviews
> and Transcripts" />
> <folder cat="Off" state="High" isBranch="false"
label="Set
> Deployment
> machine" />
> <folder cat="Off" state="High" isBranch="false"
label="send status
> reports" />
>
> </folder>
>
> </folder>
> </todolist>
>
>
> MXML file............
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
> layout="absolute"
> initialize="adgService.send()">
>
> <mx:HTTPService id="adgService" url="adg.xml"/>
> <mx:AdvancedDataGrid
>
dataProvider="{adgService.lastResult.todolist.folder}">
> <mx:columns>
> <mx:AdvancedDataGridColumn headerText="Name"
dataField="label"/>
> <mx:AdvancedDataGridColumn headerText="Age"
dataField="state"/>
> </mx:columns>
> </mx:AdvancedDataGrid>
>
> </mx:Application>
>
> Thnaks & Regards
> edeewan
Try
<mx:AdvancedDataGrid
dataProvider="{adgService.lastResult.folder}"> -
Oracle XML DOM parser - attribute values are not printing on the screen ??
Hi Everyone,
I am just trying to use oracle DOM parser to paerse one of my xml file, java file can be compiled and run agianst a xml file, But I cannot see any attribute values printing on the screen..
Appreciate if anyone can help, where I have gone wrong please?
Below is the java file:
// menna puthe DOMSample eka - duwanawa 19/12/2005
import java.io.*;
import java.net.*;
import org.w3c.dom.*;
import org.w3c.dom.Node;
import oracle.xml.parser.v2.*;
public class DOMSample { //public class eka ***
static public void main(String[] argv){ // main method eka ###
try {
if (argv.length != 1){
// Must pass in the name of the XML file...
System.err.println("Usage: java DOMSample filename");
System.exit(1);
// Get an instance of the parser
DOMParser parser = new DOMParser();
// Generate a URL from the filename.
URL url = createURL(argv[0]);
// Set various parser options: validation on,
// warnings shown, error stream set to stderr.
parser.setErrorStream(System.err);
parser.showWarnings(true);
// Parse the document.
parser.parse(url);
// Obtain the document.
Document doc = parser.getDocument();
// Print document elements
System.out.print("The elements are: ");
printElements(doc);
// Print document element attributes
System.out.println("The attributes of each element are: ");
printElementAttributes(doc);
catch (Exception e){
System.out.println(e.toString());
} // main method eka ###
static void printElements(Document doc) {
NodeList nl = doc.getElementsByTagName("*");
Node n;
for (int i=0; i<nl.getLength(); i++){
n = nl.item(i);
System.out.print(n.getNodeName() + " ");
System.out.println();
static void printElementAttributes(Document doc){
NodeList nl = doc.getElementsByTagName("*");
Element e;
Node n;
NamedNodeMap nnm;
String attrname;
String attrval;
int i, len;
len = nl.getLength();
for (int j=0; j < len; j++){
e = (Element)nl.item(j);
System.out.println(e.getTagName() + ":");
nnm = e.getAttributes();
if (nnm != null){
for (i=0; i<nnm.getLength(); i++){
n = nnm.item(i);
attrname = n.getNodeName();
attrval = n.getNodeValue();
System.out.print(" " + attrname + " = " + attrval);
System.out.println();
static URL createURL(String filename) { // podi 3 Start
URL url = null;
try {
url = new URL(filename);
} catch (MalformedURLException ex) { /// BBBBBB
try {
File f = new File(filename);
url = f.toURL();
} catch (MalformedURLException e) {
System.out.println("Cannot create URL for: " + filename);
System.exit(0);
} // BBBBBB
return url;
} // podi 3 End
} //public class eka ***
// End of program
output comes as below:
Isbn:
Title:
Price:
Author:
Message was edited by:
chandanalHi Chandanal,
I edited your code slightly and I was able to get the correct output.
I changed the following line:
for (int j=0; j >< len; j++)to:
for (int j=0; j < len; j++)I have included the complete source below:
// menna puthe DOMSample eka - duwanawa 19/12/2005
import java.io.*;
import java.net.*;
import org.w3c.dom.*;
import org.w3c.dom.Node;
import oracle.xml.parser.v2.*;
public class DOMSample {
//public class eka ***
public static void main(String[] argv) {
// main method eka ###
try {
if (argv.length != 1) {
// Must pass in the name of the XML file...
System.err.println("Usage: java DOMSample filename");
System.exit(1);
// Get an instance of the parser
DOMParser parser = new DOMParser();
// Generate a URL from the filename.
URL url = createURL(argv[0]);
// Set various parser options: validation on,
// warnings shown, error stream set to stderr.
parser.setErrorStream(System.err);
parser.showWarnings(true);
// Parse the document.
parser.parse(url);
// Obtain the document.
Document doc = parser.getDocument();
// Print document elements
System.out.print("The elements are: ");
printElements(doc);
// Print document element attributes
System.out.println("The attributes of each element are: ");
printElementAttributes(doc);
} catch (Exception e) {
System.out.println(e.toString());
// main method eka ###
static void printElements(Document doc) {
NodeList nl = doc.getElementsByTagName("*");
Node n;
for (int i = 0; i < nl.getLength(); i++) {
n = nl.item(i);
System.out.print(n.getNodeName() + " ");
System.out.println();
static void printElementAttributes(Document doc) {
NodeList nl = doc.getElementsByTagName("*");
Element e;
Node n;
NamedNodeMap nnm;
String attrname;
String attrval;
int i, len;
len = nl.getLength();
for (int j = 0; j < len; j++) {
e = (Element)nl.item(j);
System.out.println(e.getTagName() + ":");
nnm = e.getAttributes();
if (nnm != null) {
for (i = 0; i < nnm.getLength(); i++) {
n = nnm.item(i);
attrname = n.getNodeName();
attrval = n.getNodeValue();
System.out.print(" " + attrname + " = " + attrval);
System.out.println();
static URL createURL(String filename) {
// podi 3 Start
URL url = null;
try {
url = new URL(filename);
} catch (MalformedURLException ex) {
/// BBBBBB
try {
File f = new File(filename);
url = f.toURL();
} catch (MalformedURLException e) {
System.out.println("Cannot create URL for: " + filename);
System.exit(0);
// BBBBBB
return url;
// podi 3 End
} //public class eka ***-Blaise -
Parsing XML data stored as CLOB in DB and save attribute values in table
Hello,
I have a CLOB column in table that is holding XML data as follows,
<banners>
<banner-image id="0">
<type>BANNER</type>
<local-path>http.gif</local-path>
<click-through-url>www</click-through-url>
<make>Acura</make>
</banner-image>
<banner-image id="1">
<type>BANNER</type>
<local-path>http.gif</local-path>
<click-through-url>gfrty</click-through-url>
<make>BMW</make>
</banner-image>
</banners>
Now I need to parse thru the above XML data and pull the attribute values to store in another table as follows,
BANNER_IMAGE_ID | TYPE | LOCAL_PATH | CLICK_URL | MAKE
0 | BANNER | http.gif | www | Acura
1 | BANNER | http.gif | gfrty | BMW
And XML data doesn't always end up with 2 rows in this table....some times it may be 3 or 4 as well. It is just that in this example it ended up with 2 rows.
So, I would appreciate if someone can help me find a generic way of doing this,
Thank you in advance,
Madhu.This is not a reply.. sorry.
I took have a similar problem only..
can you pls help me
XML structure.
<PODetails>
<POHeader>
<CurrencyID>INR</CurrencyID>
<ExchangeRate>1</ExchangeRate>
<RefNo>0080000110</RefNo>
<VendorID>1200</VendorID>
<TransDate>2006-12-20</TransDate>
<DocRelationshipId>PURCHASE</DocRelationshipId>
<LocationID>0000102327</LocationID>
</POHeader>
<POItemDetails>
<ItemID>ARSH1332</ItemID>
<Size>L HS</Size>
<Quality>Q1</Quality>
<CustPO>rush order</CustPO>
<UOM>PC</UOM>
<Quantity>3.000</Quantity>
<PriceValue>2509.5</PriceValue>
<TaxAmount>0.00</TaxAmount>
</POItemDetails>
<POItemDetails>
<ItemID>ARSH1332</ItemID>
<Size>M HS</Size>
<Quality>Q1</Quality>
<CustPO>rush order</CustPO>
<UOM>PC</UOM>
<Quantity>2.000</Quantity>
<PriceValue>1673</PriceValue>
<TaxAmount>0.00</TaxAmount>
</POItemDetails>
<POItemDetails>
<ItemID>ARSH1556</ItemID>
<Size>39FS</Size>
<Quality>Q1</Quality>
<CustPO>rush order</CustPO>
<UOM>PC</UOM>
<Quantity>1.000</Quantity>
<PriceValue>836.5</PriceValue>
<TaxAmount>0.00</TaxAmount>
</POItemDetails>
</PODetails>
The DB is ORACLE 9i
This is stored in a XML table of type XMLTYPE.
THIS I USED THE .extract function to get the values of the nodes.
POHeader details are working fine. But when i get the POItemDetails i am getting 'ARSH1332ARSH1332ARSH1556' when i issue the command
select a.extract('/PODetails/POItemDetails/ItemID/text()').getStringVal() ItemID
FROM xmltable a
WHERE a.existsnode('//POItemDetails/ItemID')=1
Pls Help..
Regds,
Santhoshkumar.G. -
How to get the attribute value of an XML file??
How to get the attribute value of an XML file??
For example, how to get name and age attributes?
<student name="Joe" age="20" />What are you using to read the XML file??
On the assumption of JDOM - www.jdom.org. Something along the lines of:SAXBuilder builder = new SAXBuilder(true);
Document doc = builder.build(filename);
Element root = doc.getRootElement();
List children = root.getChildren();
Element thisElement = (Element)children.get(n);
String name = thisElement.getAttributeValue("name")
try
int age = Integer.parseInt(thisElement.getAttributeValue("age"));
catch (Exception ex)
throw new InvalidElementException("Expected an int.....");
}Ben -
Unsupported action attribute value 'EXCECUTE' found in XML document
Hi
I am working on IDOC->XI->DB2 scenairo
I am getitng error following error whe i try to insert and execute the stored procedure.
Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Unsupported action attribute value 'EXCECUTE' found in XML document
Following is the payload....
<?xml version="1.0" encoding="UTF-8" ?>
- <I805_Abstr_CustOutlet_MT>
- <StatementInsert>
- <STATUS action="INSERT">
<table>BI5FILMM.BSOMSAPP</table>
- <access>
<OUTLET_NO>12</OUTLET_NO>
<OUTLET_RF>20</OUTLET_RF>
<OMFUNC>CRT</OMFUNC>
<STATUS>N</STATUS>
<IFCEDATE>1080626</IFCEDATE>
<IFCETIME>094220</IFCETIME>
</access>
</STATUS>
</StatementInsert>
- <StatementProce>
- <STATUS action="EXCECUTE">
<table>CC5PTF.BSOMPSAP</table>
<Para1 IsInput="true" type="CHAR">BI5FILMM</Para1>
<Para2 IsInput="true" type="CHAR">BMIJOBD</Para2>
</STATUS>
</StatementProce>
</I805_Abstr_CustOutlet_MT>Check ur XML format with the one mentioned in this
http://help.sap.com/saphelp_nw2004s/helpdata/en/4d/8c103e05df2e4b95cbcc68fed61705/content.htm -
Read a XML node value/attribute value from a CLOB
Hello,
I can write SQL/ - PL/SQL "straightforward" but now I have a problem what is to big for me. I hop that someone can help.
We create by code a xml structure and write these into the oracle database CLOB field. I'm sorry to say that a xml text structure is written into a clob in stead of a xmltype field. (it's a design failure?) It's a large xml structure. I believe I can't attach a file so I put at the end of this discussion a light example of the xml structure.
It's a xml with quartervalue's, so there are 35040 detail rows (24h * 4 * 365days). I want to accumulate the the attribute Amount value 9. The amount value is in the Detail node a attribute but at the end you can see that for the DST are also 4 value's, but these are not attribute value's but node value's. (In this case it are four value's in some cases there is one DST amount value.
Can somebody help me how to accumulate all the detail attribute value Amount with the node value Amount of the DST tag?
XML structure:
<?xml version="1.0"?>
<Message xmlns:ns1="http://automaticdealcapture/">
<BusinessDocument messageDateTime="2013-10-25T13:59:31+02:00" ediReference="LO-461967" messageName="New" businessSector="Z" documentFunction="Original">
<DocumentData>
<ns1:Adcs>
<ns1:Package>
<ns1:Deal>
<ns1:ProductCode>PWCODE</ns1:ProductCode>
<ns1:Action>NEW</ns1:Action>
<ns1:Memo1>MemoField</ns1:Memo1>
<ns1:Details>
<ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="00:00:00" Timee="01:00:00" Amount="0.0153" Price="11.111"/>
<ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="01:00:00" Timee="02:00:00" Amount="0.015" Price="22.222"/>
etc. 350040 detail rows.
</ns1:Details>
<ns1:DSTS>
<ns1:Year Val="2014">
<ns1:DST Period="1">
<ns1:Amount>0.0146</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="2">
<ns1:Amount>0.0222</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="3">
<ns1:Amount>0.0444</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="4">
<ns1:Amount>0.0146</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
</ns1:Year>
</ns1:DSTS>
</ns1:Deal>
</ns1:Package>
</ns1:Adcs>
</DocumentData>
</BusinessDocument>
</Message>From what I know, extracting the "Amount" values in the Details section and the "Amount" values in the DSTS section would be two different SELECT statements.
Both of these will use XMLTable() to extract the values.
BTW - If you need more information on this, post up in the XML/XML DB forum section for more complex help. (eg getting YEAR with the DSTS Amount values)
as far as XML size goes, I've seen oracle handle a 100MB XML document without problems.
(just understand, it will be 'slow')
This one will give you the Amount values from the DSTS section:
with xml_data as ( SELECT
XMLType('<?xml version="1.0"?>
<Message xmlns:ns1="http://automaticdealcapture/">
<BusinessDocument messageDateTime="2013-10-25T13:59:31+02:00" ediReference="LO-461967" messageName="New" businessSector="Z" documentFunction="Original">
<DocumentData>
<ns1:Adcs>
<ns1:Package>
<ns1:Deal>
<ns1:ProductCode>PWCODE</ns1:ProductCode>
<ns1:Action>NEW</ns1:Action>
<ns1:Memo1>MemoField</ns1:Memo1>
<ns1:Details>
<ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="00:00:00" Timee="01:00:00" Amount="0.0153" Price="11.111"/>
<ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="01:00:00" Timee="02:00:00" Amount="0.015" Price="22.222"/>
</ns1:Details>
<ns1:DSTS>
<ns1:Year Val="2014">
<ns1:DST Period="1">
<ns1:Amount>0.0146</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="2">
<ns1:Amount>0.0222</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="3">
<ns1:Amount>0.0444</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="4">
<ns1:Amount>0.0146</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
</ns1:Year>
</ns1:DSTS>
</ns1:Deal>
</ns1:Package>
</ns1:Adcs>
</DocumentData>
</BusinessDocument>
</Message>') as XMLDATA from dual
select Y.amount
from xml_data X,
XMLTable( XMLNAMESPACES( 'http://automaticdealcapture/' as "ns1"),
'/Message/BusinessDocument/DocumentData/ns1:Adcs/ns1:Package/ns1:Deal/ns1:DSTS/ns1:Year/ns1:DST'
passing X.XMLData
COLUMNS
amount Number PATH '/ns1:DST/ns1:Amount'
) Y;
Replace the XMLTable() with the one below to get the Amount from the Details section:
XMLTable( XMLNAMESPACES( 'http://automaticdealcapture/' as "ns1"),
'/Message/BusinessDocument/DocumentData/ns1:Adcs/ns1:Package/ns1:Deal/ns1:Details/ns1:Detail'
passing X.XMLData
COLUMNS
amount number PATH '/ns1:Detail/@Amount'
) Y; -
Update attribute value in xml db in Oracle 10g
I have a table with XML blob data
The root element is invoice with an element billInfo and attribute type0
I'm trying to update the attribute value using the following sql but it is not working.
the sql goes to sucess but the value is not updated.
Looking for a solution and I appreciate your help
update sc.table_name
set xml_cb= updateXML(xml_cb,'/invoice/billInfo/@type0','A')
where id = 1 succeeded.
select id,
extractValue(xml_cb,'/invoice/billInfo/@type0') type_val
from sc.table_name
where id =1;
ID TYPE_VAL
1 KWhat database version are you using?
could you show us the outcome of:
SQL> select dbms_metadata.get_ddl('TABLE','TABLE_NAME','SC') from dual;
and/or a
SQL> describe SC.TABLE_NAME -
Select XML Node by a specific attribute value
I am newbie for LifeCyle.
This might be an easy question, but it really got me here.
I am trying bind xml data into a Drop-Down List. The databinding is working fine, but I would like to have more specific node selected from the xml file by using a attribute value.
for example Code in AS 3.0
root.node.(@id=="1").subNode
How could i do the same thing in LifeCycle Designer 8.0
Thank you in advance!!!there's no native method for this, maybe you should create some functions for this. just like
private function setAttribute(node:XML, name:String, value:String, index:int = -1):void
var attrs:XMLList = node.attributes().copy(),
l:int = attrs.length();
if(index == -1 || index > l - 1)
node.@[name] = value;
else
delete node.@*;
var idx:int = 0;
for (var i:int = 0; i < l + 1; i++)
if(i == index)
node.@[name] = value;
else
var attr:XML = attrs[idx];
node.@[attr.name()] = attr.toString();
idx++;
and use it like this:
setAttribute(myNode, "otherAttribute", "abc", 0);
Maybe you are looking for
-
With more than one window open in firefox 4 I starts to drain my memory
With mozilla 4 I have more than one window open and my memory which has 2 gigs in it starts to drain and then everything freezes.
-
My iPhone 4 has been disabled because I cannot remember the passcode. I plug my phone into the computer but it does not bring me to a place where I can restore.
-
Quiz stuck on a slide after failing and retaking
Hi, I have a quiz which hangs on a particular slide after user retakes it. The slide appears with the objects prearranged (draggable shapes) and the user cannot actually drag any smart shape. Hence stuck in there... Any ideas are appreciated. Thanks
-
Grouping of selections into one heading in BEX
Dear all, I have a scenario wherein KF1,KF2 - Monthly KF3,KF4- Quarterly KF5,KF6 - Yearly The titles shoulld appear in the columns for the key figures as the Curr month, Curr Qtr and Current year. I can do Key figure selections ;But to group the set
-
Fireworks CS4 - layers display incorrectly
I created a web page graphic in FW CS4 and it looked like this: Good version Now, when I reopen it up in FW CS4, it looks like this: Bad version I exported it as a web page before and that looks fine. I can even re-open the PNG file in Photoshop OR F