Accessing XML node value
Hi,
Is there any method to get node value other than getTextContent() in org.w3c.dom.Node?
Here is my XML
<data>value<data>
Hoe can i get "value" using java?
Thanks
Shagil
The text "value" is a child node of element node "data". So, by following the tree structure of DOM, you'll get this text by asking for the node value of the (first) child node of the element.
Node data = ...;
if (data.hasChildNodes()) {
String text = data.getFirstChild().getNodeValue();
// use text
}
Similar Messages
-
Store XML node value into an array with node element name
Hi,
I have the following code that displays the node element with the
corresponding node value. I want to store the values in an array in
reference to the node name.
i.e.
XML (my xml is much bigger than this, 300 elements):
<stock>
<symbol>SUNW</symbol>
<price>17.1</price>
</stock>-----
would store the following:
*data[symbol] = SUNW;*
*data[price] = 17.1;*
Thanks in advance,
Tony
test.jsp
Here's my source code:
<html>
<head>
<title>dom parser</title>
<%@ page import="javax.xml.parsers.*" %>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="dombean.*" %>
</head>
<body bgcolor="#ffffcc">
<center>
<h3>Pathways Info</h3>
<table border="2" width="50%">
<jsp:useBean id="domparser" class="dombean.MyDomParserBean" />
<%
Document doc = domparser.getDocument("c:/stocks/stocks.xml");
traverseTree(doc, out);
%>
<%! private void traverseTree(Node node,JspWriter out) throws Exception {
if(node == null) {
return;
int type = node.getNodeType();
switch (type) {
// handle document nodes
case Node.DOCUMENT_NODE: {
out.println("<tr>");
traverseTree
(((Document)node).getDocumentElement(),
out);
break;
// handle element nodes
case Node.ELEMENT_NODE: {
String elementName = node.getNodeName();
//if(elementName.equals("MOTHER-OCC-YRS-PREVIOUS")) {
//out.println("</tr>");
out.println("<tr><td>"+elementName+"</td>");
NodeList childNodes =
node.getChildNodes();
if(childNodes != null) {
int length = childNodes.getLength();
for (int loopIndex = 0; loopIndex <
length ; loopIndex++)
traverseTree
(childNodes.item(loopIndex),out);
break;
// handle text nodes
case Node.TEXT_NODE: {
String data = node.getNodeValue().trim();
//if((data.indexOf("\n") <0) && (data.length() > 0)) {
out.println("<td>"+data+"</td></tr>");
%>
</table>
</body>
</html>
{code}
*MyDomParserBean.java*
Code: package dombean;
{code:java}
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.io.*;
public class MyDomParserBean
implements java.io.Serializable {
public MyDomParserBean() {
public static Document
getDocument(String file) throws Exception {
// Step 1: create a DocumentBuilderFactory
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
// Step 2: create a DocumentBuilder
DocumentBuilder db = dbf.newDocumentBuilder();
// Step 3: parse the input file to get a Document object
Document doc = db.parse(new File(file));
return doc;
{code}
Edited by: ynotlim333 on Sep 24, 2007 8:41 PM
Edited by: ynotlim333 on Sep 24, 2007 8:44 PM
Edited by: ynotlim333 on Sep 24, 2007 8:45 PMI still need to store it in an array because its 300 elements in the XML stocks.
I've done the following but its not working, i'm getting error codes. I think its an easy fix. I'd also like to pass a String instead of a .xml document b/c my xml is stored inside a DB. Any suggestions on that?
<html>
<head>
<title>dom parser</title>
<%@ page import="javax.xml.parsers.*" %>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="org.*" %>
</head>
<body bgcolor="#ffffcc">
<center>
<h3>Pathways Info</h3>
<table border="2" width="50%">
<jsp:useBean id="domparser" class="org.MyDomParserBean" />
<%
Document doc = domparser.getDocument("c:/stocks/stocks.xml");
traverseTree(doc, out);
%>
<%!
public String element_store = null;
public String[] stock_data = new String[400];
private void traverseTree(Node node,JspWriter out) throws Exception {
if(node == null) {
return;
int type = node.getNodeType();
switch (type) {
// handle document nodes
case Node.DOCUMENT_NODE: {
out.println("<tr>");
traverseTree
(((Document)node).getDocumentElement(),
out);
break;
// handle element nodes
case Node.ELEMENT_NODE: {
String elementName = node.getNodeName();
element_store = elementName;
//if(elementName.equals("MOTHER-OCC-YRS-PREVIOUS")) {
//out.println("</tr>");
NodeList childNodes =
node.getChildNodes();
if(childNodes != null) {
int length = childNodes.getLength();
for (int loopIndex = 0; loopIndex <
length ; loopIndex++)
traverseTree
(childNodes.item(loopIndex),out);
break;
// handle text nodes
case Node.TEXT_NODE: {
String data = node.getNodeValue().trim();
if((data.indexOf("\n") <0) && (data.length() > 0)) {
out.println("<tr><td>"+element_store+"</td>");
out.println("<td>"+data+"</td></tr>");
stock_data[element_store]=data;
%>
</table>
</body>
</html> -
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; -
How to Edit the xml node value using flex from the front end UI
Hi All,
I am having a use case with flex 4.6
1> To read the external xml file
2> Display the tree structure in the front end UI
3> Edit the node values of the xml file from the front end UI and save it back
How to go about the above use case, any blogs or links on the above case will be help
Thanks,
AlokCheck this is example:
http://blog.flexexamples.com/2009/07/23/deleting-nodes-from-an-xml-object-in-flex/ -
Matching event.target to XML node value
I want Montana data to appear when I click the state of
Montana (and so on throughout the 50 states). Montana is the
instance name of my simple button on the state of Montana.
Something's not quite right about this line of code:
if (pEvent.target == myXML.statename
) { ...then do something ...}
The code works fine if I say
if (pEvent.target == Montana)
Do I have to convert the myXML node value to text or
something?Solution:
if (pEvent.target.name == myXML.statename -
Use XML Node Value as Node name and as attribute name
im quite new to XML and XLST. I got an Open Office XML file that I transformed with XLST.
<?xml version="1.0" encoding="UTF-8"?>
<ooo_calc_export scriptVersion="2.2.0" scriptUpdate="2010-12-19" scriptURL="http://www.digitalimprint.com/misc/oooexport/" scriptAuthor="vjl">
<ooo_sheet num="1" name="Blatt1">
<ooo_row><Artikelnummer>C12-34567</Artikelnummer><ArttikelnummerAlt/><Details>AAA AAA AAA AAA</Details><Abmessungen/><Bildpfad>file:///cmyk/C12-34567.PSD</Bildpfad><EK>1234,-</EK><VK>3456,-</VK>
</ooo_row>
<ooo_row><Artikelnummer>C23-45678</Artikelnummer><ArttikelnummerAlt/><Details>BaB BaB BBB BBB</Details><Abmessungen/><Bildpfad>file:///cmyk/cmyk/C23-45678.PSD</Bildpfad><EK>2345,-</EK><VK>4567,-</VK>
</ooo_row>
<ooo_row><Artikelnummer>C34-56789</Artikelnummer><ArttikelnummerAlt/><Details>CaC CaC CaC CaC uli</Details><Abmessungen/><Bildpfad>file:///cmyk/cmyk/C34-56789.PSD</Bildpfad><EK>3456,-</EK><VK>5678,-</VK>
</ooo_row>
</ooo_sheet>
</ooo_calc_export>
I transformed the XML with the following XLST:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method = "xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="ooo_sheet">
<xsl:element name="Import">
<xsl:for-each select="ooo_row">
<xsl:element name="Artikel">
<xsl:element name="Text">
<xsl:copy-of select="Artikelnummer"/>
<xsl:copy-of select="Details"/>
<xsl:copy-of select="Abmessungen"/>
<xsl:copy-of select="EK"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
The result is:
<?xml version="1.0" encoding="UTF-8"?>
<Import>
<Artikel>
<Text>
<Artikelnummer>C12-34567</Artikelnummer>
<Details>AAA AAA AAA AAA</Details>
<Abmessungen/>
<EK>1234,-</EK>
</Text>
</Artikel>
<Artikel>
<Text>
<Artikelnummer>C23-45678</Artikelnummer>
<Details>BaB BaB BBB BBB</Details>
<Abmessungen/>
<EK>2345,-</EK>
</Text>
</Artikel>
<Artikel>
<Text>
<Artikelnummer>C34-56789</Artikelnummer>
<Details>CaC CaC CaC CaC uli</Details>
<Abmessungen/>
<EK>3456,-</EK>
</Text>
</Artikel>
</Import>
I need another child within the node "Artikel" named "Bild". It should have an "href" attribute. The value of the attribute should be the value in the node "Bildpfad".
The result of this transformation should be
<Artikel>
<Text>
<Artikelnummer>C34-56789</Artikelnummer>
<Details>CaC CaC CaC CaC uli</Details>
<Abmessungen/>
<EK>3456,-</EK>
</Text>
<Bild href="file:///cmyk/C12-34567.PSD"></Bild>
</Artikel>
I want to import this XML into Indesign. It seems that the images path needs to be in a href attribute so Indesign accepts the node as an image object.
Another problem is that Indesign won't import the original xml with selection of the listed xsl to tranform the xml. So I used another xml editor instead to perform the transformation.
Thank you all for your help!Hi Dorian_fs,
I think we're still missing details here on what exactly it
is you're trying to do? Are you loading this XML via a data set? In
which case, Don's samples would apply? Or are you trying to load
XML independent of data sets and regions, in which case, you are
looking for something that simplifies the access of data from the
resulting XML document? If the latter than perhaps you want to use
XMLDocToObject:
http://labs.adobe.com/technologies/spry/samples/utils/XMLDocToObject.html
--== Kin ==-- -
Hi,
For some queries of mine (those with joins and foreign keys) the sql_XXX.Result shows me "---" and "NA" at some nodes. To remove this I have been built another XML Document and using the Repeat Action to changing this value to "".
It works very well for me, but I would like to know if there is a way to change this directly on sql_XXX.Result before linking with the Output parameter of transaction.
Thank you in advance,
Nuno CunhaWhat you are describing is how MII conveys null values from the database inside the XML results (which is essentially a structured string). The dashes are for string fields, NA is for numerical columns, and TimeUnavailable will be for datetime fields.
This is expected behavior and should be consistent for the corresponding data types. If you prefer to have an empty node then I would recommend using the case statement in your SQL query template to check for the IS NULL situation and adjust accordingly.
The applets will work in conjunction with the null representations in the data, so a lot of you decision relates to the end result from a UI perspective, but dealing with nulls at the query level will be way more efficient than some repeater loop and replace mechanism in your TRX. -
I have an XML Object as a property of my Class. I want to
dynamically update some of the values of the nodes. What is the
best way to do this? Should I use XML.replace()?
See attached pseudo code for my attempt."ericbelair" <[email protected]> wrote in
message
news:gfk97h$60g$[email protected]..
>I have an XML Object as a property of my Class. I want to
dynamically
>update
> some of the values of the nodes. What is the best way to
do this? Should I
> use
> XML.replace()?
>
> See attached pseudo code for my attempt.
>
> /* I start with this: */
>
> <Report>
> <prop1>4</prop1>
> <prop2>2255</prop2>
> <prop3>true</prop3>
> <prop4>false</prop4>
> <prop5>true</prop5>
> </Report>
>
> /* I want this result (change the value of node
"prop5"): */
>
> <Report>
> <prop1>4</prop1>
> <prop2>2255</prop2>
> <prop3>true</prop3>
> <prop4>false</prop4>
> <prop5>false</prop5>
> </Report>
>
> /* I tried this: */
>
> var reportXML:XML =
> <Report>
> <prop1>4</prop1>
> <prop2>2255</prop2>
> <prop3>true</prop3>
> <prop4>false</prop4>
> <prop5>true</prop5>
> </Report>;
>
> var myArray:Array = [{xmlNodeName: "prop5", value:
false}];
>
> for each (var item:Object in myArray)
> {
> report.xml[item.xmlNodeName] =
> reportSection.value.toString();
> }
Try
report.xml.child(item.xmlNodeName).text() =
reportSection.value.toString(); -
Flash Builder 4 List controls trimming spaces from XML node values
I'm trying to migrate my Flex 3 application to Flash builder 4. One issue that I have is that one of my datasources returns a list of cities and regions. To get the regions to display in the correct order in Flex 3, a space was added to to their name in the database (ie. "West", "Northwest" are stored in the database as " West" and " Northwest" so that when sorted by the sql query they would appear at the top and gets translated to XML to fill in a list box or combo box in my Flex 3 application. I have functions that take that selected city or region value from the combo box and queries the database for various performance metrics. In migrating to Flash Builder 4, I noticed that the spaces in the region names no longer appear in the combo boxes. When I show the data in a datagrid, the spaces are still there but when populating a combo box or list box, the leading space gets trimmed. This is an issue since if a user selects the value "West", it doesn't find it in the database since it is listed as " West". This wasn't an issue in Flex Buider 3. Is there a work around or parameter that I can set to force the combo box or list box to show the data as-is versus having it trim off the leading spaces for my regions?
Also, a stupid question, in Flex 3, you were able to find the select value of a combo box by using comboBox.text. What is the equivalent in Flash Builder 4? Do I need to do comboBox.selectedItem.Region.toString() now or is there a shortcut to pull the text from the combo box?I think you want this:
private function onLoadPortfolioData(event:ResultEvent):void
var obj:XMLList = event.result.img as XMLList;
if (obj.length > 0)
_imgCollection = new XMLListCollection(obj);
pictureList.dataProvider = _imgCollection;
If this post answers your question or helps, please mark it as such. Thanks!
http://www.stardustsystems.com
Adobe Flex Development and Support Services -
Upadting a XML node value to another table
Hi guys,
Can you please tell me, what is wrong with the below query
update csabcd cs set (cs.ELEMENT,cs.ELEMENT2,cs.ELEMENT3) =
(select x.* from abcde a, xmltable ('.' passing XMLTYPE(a.xml)
columns mort1 varchar2 (80) path '/alert/tab1/details/Element',
mort2 varchar2 (80) path '/alert/tab1/details/Element2',
mort3 varchar2 (80) path '/alert/tab1/details/Element3'
) x where cs.aid = a.aid);i get this error
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00229: input source is empty
Error at line 0
ORA-06512: at "SYS.XMLTYPE", line 254
ORA-06512: at line 1Edited by: Depakjan on Oct 21, 2010 1:35 PMWell from that sample, the XMLTABLE works ok...
SQL> ed
Wrote file afiedt.buf
1 with abcde as (select '<?xml version="1.0" encoding="UTF-8"?>
2 <alert>
3 <tab0 comment="section in XSL component" name="Initial Information">
4 <details>
5 <Priority>0001</Priority>
6 <DateVRUClaimInitiated>2010-06-29</DateVRUClaimInitiated>
7 </details>
8 <contacts comment="grid in XSL component">
9 many child nodes here
10 </contacts>
11 </tab0>
12 <tab1 comment="section in XSL component" name="Additional Information">
13 <details comment="list collection in XSL component">
14 <Channel1>123</Channel1>
15 <Element>1234</Element>
16 <Element2>1234</Element2>
17 <Element3>1234</Element3>
18 </details>
19 <IPAddresses>
20 Many child nodes here
21 </IPAddresses>
22 <ANIPhones>
23 Many child nodes here
24 </ANIPhones>
25 </tab1>
26 </alert>' as xml from dual)
27 --
28 --
29 --
30 select x.*
31 from abcde a
32 ,xmltable ('.'
33 passing xmltype(a.xml)
34 columns mort1 varchar2 (80) path '/alert/tab1/details/Element'
35 ,mort2 varchar2 (80) path '/alert/tab1/details/Element2'
36 ,mort3 varchar2 (80) path '/alert/tab1/details/Element3'
37* ) x
SQL> /
MORT1 MORT2 MORT3
1234 1234 1234
SQL>There must be something else in the XML that's causing the problem.
What happens if you just do:
select xmltype(xml) from abcde(add appropriate where clause for particular ID if necessary)
Is it able to convert the xml strings to xmltype ok? -
DOM Scripting - accessing XML CDATA values
HI Folks,
Not sure if this is the write forum, but I'm trying to use Javascript to output XML values onto my webpage, see below.
This works fine, but when I try and get he values in a CDATA tag, I get undefined or null.
Can anyone please tell me how to get CDATA content?
<script type="text/javascript"
xmlDoc=loadXMLDoc("news.xml");
x=xmlDoc.getElementsByTagName('title');
for (i=0;i<x.length;i++)
document.write(x[i].childNodes[0].data);
document.write("<br />");
</script>
XML
<items>
<item>
<title>
<![CDATA[text goes in here]]>
</title>
</item>
</items>I think you will have more success on a JavaScript forum.
Mack -
Ok I need a quick lesson on accessing various tags in a xml
file and displaying them. I have a rather messy xml file that
dynamically created and the structure cannot be changed due to an
Excel application that is already accessing it.
Here's the xml:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Files>
<active>
<record>
<sendto>Joe D</sendto>
<head>
<level1>
<submited>true</submited>
<name>MIKE B</name>
<str>1</str>
<date>7/18/2006</date>
<notes>get this loaded!!!!!!!!!!!!!!!!!</notes>
</level1>
<level2>
<submited>false</submited>
<name></name>
<str></str>
<date></date>
<notes></notes>
</level2>
<level3>
<submited>false</submited>
<name></name>
<str></str>
<date></date>
<notes></notes>
</level3>
<level4>
<submited>false</submited>
<name></name>
<str></str>
<date></date>
<notes></notes>
</level4>
</head>
<itemcd>1234567</itemcd>
<desc>TEST</desc>
<retail>5</retail>
<aisle>AA01</aisle>
<replcst>2</replcst>
<pack>1</pack>
<upc>123456789999</upc>
<vendor>EMRYW</vendor>
<venditemcd>1234567</venditemcd>
<grp>2</grp>
<sec></sec>
<insaft></insaft>
<sellum default="each"></sellum>
<fracu default="i"></fracu>
<decp default="0"></decp>
<allowfr default=" "></allowfr>
<prium default="each"></prium>
<selluf default="1.00000"></selluf>
<priscal default="1"></priscal>
<stockum default="each"></stockum>
<itemstyp default="0"></itemstyp>
<traqoh default="y"></traqoh>
<rcvum default="each"></rcvum>
<rcvuf default="1.00000"></rcvuf>
<rcvscal default="1"></rcvscal>
<shipum default="each"></shipum>
<shipuf default="1.00000"></shipuf>
<stockingstr>
<str1>true</str1>
<str2>false</str2>
<str3>false</str3>
</stockingstr>
<pricematlev default="0"></pricematlev>
<qbreaktable default="0"></qbreaktable>
<taxflg default="y"></taxflg>
<gstcd default="0"></gstcd>
<tradedisf default="n"></tradedisf>
<promptpayf default="y"></promptpayf>
<commflg default="y"></commflg>
<additdescf default="n"></additdescf>
<talleyitemf default="n"></talleyitemf>
<nonstkitem default="n"></nonstkitem>
<assemblyitemf default="n"></assemblyitemf>
<assemblyitemtype
default="0"></assemblyitemtype>
<assemblyledtm default="0"></assemblyledtm>
<assemblywrkuts default="n/a"></assemblywrkuts>
<billmattyp default="0"></billmattyp>
<serialnumf default="n"></serialnumf>
<bascomitemf default="n"></bascomitemf>
<bascomitemcd></bascomitemcd>
<lotctrlf default="n"></lotctrlf>
<lotctrlnum default="0"></lotctrlnum>
<relitemmsgnum default="0"></relitemmsgnum>
<hazmatnum default="0"></hazmatnum>
<strydf default="s"></strydf>
<keyitemf default="n"></keyitemf>
<ctrlitemf default="n"></ctrlitemf>
<talleyindiv></talleyindiv>
<textfld2></textfld2>
<numfld1 default="0"></numfld1>
<numfld2 default="0"></numfld2>
<glacctcd default=""></glacctcd>
<stkitemrptf default="y"></stkitemrptf>
<lifopolnum default="0"></lifopolnum>
<lifosampf default="n"></lifosampf>
<pricetabname default=""></pricetabname>
<invcstperc default="0.00">
<str1></str1>
<str2></str2>
<str3></str3>
</invcstperc>
<invcritfac
default="0.00"><str1></str1><str2></str2><str3></str3></invcritfac>
<invglnum
default="0"><str1></str1><str2></str2><str3></str3></invglnum>
<invlngrngfac
default="0.00"><str1></str1><str2></str2><str3></str3></invlngrngfac>
<invminq default="1">
<str1></str1>
<str2></str2>
<str3></str3>
</invminq>
<invmaxq default="2">
<str1></str1>
<str2></str2>
<str3></str3>
</invmaxq>
<minmaxtab default="DO_NOT_ORDER">
<str1></str1>
<str2></str2>
<str3></str3>
</minmaxtab>
<invmingpperc default="49">
<str1></str1>
<str2></str2>
<str3></str3>
</invmingpperc>
<invordq
default="0"><str1></str1><str2></str2><str3></str3></invordq>
<price1><str1></str1><str2></str2><str3></str3></price1>
<price2><str1></str1><str2></str2><str3></str3></price2>
<price3><str1></str1><str2></str2><str3></str3></price3>
<price4><str1></str1><str2></str2><str3></str3></price4>
<price5><str1></str1><str2></str2><str3></str3></price5>
<price6><str1></str1><str2></str2><str3></str3></price6>
<price7><str1></str1><str2></str2><str3></str3></price7>
<price8><str1></str1><str2></str2><str3></str3></price8>
<aisle default="XXXXX">
<str1>AA01</str1>
<str2></str2>
<str3></str3>
</aisle>
<bin><str1></str1><str2></str2><str3></str3></bin>
<shelf><str1></str1><str2></str2><str3></str3></shelf>
<invstdcst><str1></str1><str2></str2><str3></str3></invstdcst>
<manminmax><str1></str1><str2></str2><str3></str3></manminmax>
<text2><str1></str1><str2></str2><str3></str3></text2>
<numer1><str1></str1><str2></str2><str3></str3></numer1>
<numer2><str1></str1><str2></str2><str3></str3></numer2>
<keyword default=""></keyword>
<note default="">get this
loaded!!!!!!!!!!!!!!!!!</note>
</record>
</active>
</Files>
Here's the code I have so far:
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="
http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:local="*">
<XML id="feedData" source="index.xml"/>
<DataGrid dataProvider="{feedData..active.record}"
x="324" y="138" width="500">
<columns>
<DataGridColumn id="SubmittedBy" headerText="Submitted
By" dataField=""/>
<DataGridColumn headerText="Item" dataField="itemcd"/>
<DataGridColumn headerText="Description"
dataField="desc"/>
</columns>
</DataGrid>
</Application>
What I want to know is how to access and put into the "
Submitted By" column
<Files><active><record><head><level1><name>
Any help would be great since I'm stuck.After a little digging and a couple cups of coffee, I managed
to pull some data extracting from xml into a datagrid. I can access
attributes, node values, etc...
One thing I did notice, is that you have to refresh the
application if you have dynamic data constantly being updated. So
here is some code to help some of you out:
First some sample XML (index.xml):
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<records>
<active name="John" id="1234" location="New York">
<job>Architect</job>
<address>111 Salisbury Rd</address>
</active>
<inactive name="Chris" id="5432" location="California">
<job>Web Designer</job>
<address>888 Orchard Rd</address>
</inactive>
</records>
Code with two tabs one name (
Active), other named (
Inactive):
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:local="*" pageTitle="Test App"
creationComplete="srv.send()">
<mx:HTTPService id="srv" url="
http://www.domain.com/index.xml?rand=math.random();"
resultFormat="e4x" useProxy="false" showBusyCursor="true" />
<mx:XMLListCollection id="xActive"
source="{srv.lastResult.active}" />
<mx:XMLListCollection id="xInActive"
source="{srv.lastResult.inactive}" />
<mx:script>
<[[
private function RefreshData():void{
xActive.refresh();
xInActive.refresh();
]]>
</mx:Script>
<mx:TabNavigator>
<mx:Canvas label="Active" width="100%" height="100%"
id="canvas1" initialize="RefreshData();">
<mx:DataGrid id="activeData" dataProvider="{xActive}"
selectedIndex="0" editable="true" enabled="true">
<mx:columns>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@name" headerText="Name"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@id" headerText="ID"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@location" headerText="Location"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="job" headerText="Job"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="address" headerText="Address"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:Canvas label="Inactive" width="100%" height="100%"
id="canvas2" initialize="RefreshData();">
<mx:DataGrid id="inactiveData" dataProvider="{xInActive}"
selectedIndex="0" editable="true" enabled="true">
<mx:columns>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@name" headerText="Name"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@id" headerText="ID"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="@location" headerText="Location"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="job" headerText="Job"/>
<mx:DataGridColumn textAlign="center" resizable="false"
dataField="address" headerText="Address"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
</mx:TabNavigator>
</mx:Application> -
How to get Total Number of XML Nodes?
Hello All,
I have a Flash program I'm doing in Actionscript 3, using CS6.
I'm using the XMLSocket Class to read-in XML Data. I will write some sample XML Data that is being sent to the Flash
program below...
I know with this line here (below) I can access the 4th "element or node" of that XML Data.
Accessing XML Nodes/Elements:
// *I created an XML Variable called xml, and "e.data" contains ALL the XML Data
var xml:XML = XML(e.data);
// Accessing the 4th element of the data:
xml.MESSAGE[3].@VAR; ---> "loggedOutUsers"
xml.MESSAGE[3].@TEXT; ---> "15"
SAMPLE XML DATA:
<FRAME>
0 <MESSAGE VAR="screen2Display" TEXT="FRAME_1"/>
1 <MESSAGE VAR="numUsers" TEXT="27"/>
2 <MESSAGE VAR="loggedInUsers" TEXT="12"/>
3 <MESSAGE VAR="loggedOutUsers" TEXT="15"/>
4 <MESSAGE VAR="admins" TEXT="2"/>
</FRAME>
I'm new to Flash and Actionscript but I'm very familiar with other languages and how arrays work and such, and I know for
example, in a Shell Script to get the total number of elements in an array called "myArray" I would write something like
this --> ${#myArray[@]}. And since processing the XML Data looks an awful lot like an array I figured there was maybe
some way of accessing the total number of "elements/nodes" in the XML Data...?
Any thoughts would be much appreciated!
Thanks in Advance,
MattHey vamsibatu, thanks again for the quick reply!
Ohhh, ok I gotcha. That makes more sense.
So I just tried this loop below and I guess I could use this and just keep assigning an int variable to the output so
when it finishes I will be left with a variable containing the total number of elements:
for (var x:int in xml.MESSAGE)
trace("x == " + x);
*Which OUTPUTS the Following:
x == 0
x == 1
x == 2
x == 3
x == 4
So I guess I could do something like this and when the loop completes I will be left with the total number of elements/nodes...
var myTotal:int;
for (var x:int in xml.MESSAGE)
myTotal = x;
// add '1' to myTotal since the XML Data is zero-based:
myTotal += 1;
trace("myTotal == " + myTotal);
*Which Prints:
"myTotal == 5"
Thanks again for you suggestions, much appreciated!
I think that should be good enough for what I needed. Thanks...
Thanks Again,
Matt -
Getting Node Value of an XML element in JAVA.
Hi,
In my application, I have got the exact node that I want by parsing the document, but the node value returned is null as the node is an element and the Java Documentation does specify that it will return null. I would like to know if there in any alternative way by which I can parse the document and get the specified value of the node or element. Kindly help.Hi,
i am using the dom parser. My code is as follows.
Document xmlDocument, outputDoc;
DocumentBuilderFactory dbfObject = DocumentBuilderFactory.newInstance();
DocumentBuilder dbObject = dbfObject.newDocumentBuilder();
xmlDocument = dbObject.parse("IPD_Response.xml");
Element dd = xmlDocument.getDocumentElement();
NodeList ItemAttributes = dd.getElementsByTagName("Element Name");
System.out.println("element" + ItemAttributes.item(0));
Node ss = ItemAttributes.item(0);
NodeList bb = ss.getChildNodes();
Node cc = ss.getFirstChild();
System.out.println("element sibling1 "+bb.item(0));
System.out.println("element sibling 2"+bb.item(1));
System.out.println("element sibling 3"+bb.item(2));
System.out.println("element child "+cc);
Node aa = bb.item(0);
NodeList qqq = aa.getChildNodes();
System.out.println("element sibling1---1 "+qqq.item(0));
System.out.println("element sibling1---1 "+qqq.item(1));
Node fff = qqq.item(0);
Node aaa = qqq.item(1);
String value1 = fff.getNodeValue();
String value2 = aaa.getNodeValue();
System.out.println("1st value "+value1+" 2nd value "+value2);What my code does is gets all the elements within a particular tag. After that i look for the child nodes, which i have done successfully. But when i get the value using getNodeValue(); method it will be null as per the Java Docs. Is there any other way by which i can get the node value. Kindly help.
How do you parse the XML Document ?
Are you using a DOM Document ?
Which parser do you use ?
How do you access the Element ?
Post the releveant part of the code and using the
[code ] tags as described in[url=http://forum.java.sun.com/help.jspa?sec=formattin
g]Formatting tips
andi -
Assigning a node value from an XML variable to a String type in Weblogic Process Integrator
Hi,
Is there any way to assign a node value from an XML variable to a String variable
in Weblogic Process Integrator...
Thanx.
Narendra.Nerendra
Are you talking about using Xpath on the XML document and assigning to a
variable, it is unclear what you are asking
Tony
"Narendra" <[email protected]> wrote in message
news:3bba1215$[email protected]..
>
Hi,
Is there any way to assign a node value from an XML variable to a Stringvariable
in Weblogic Process Integrator...
Thanx.
Narendra.
Maybe you are looking for
-
How can I delete multiple emails on my Samsung Stratosphere at once?
How can I delete multiple emails on my Samsung Stratosphere at once? I use AOL and when I delete the emails off of my computer, they do not delete from my phone. So I have hundreds of unwanted messages showing on my phone but I have not found an opti
-
I'm trying to sync my new 5s with Itunes on my Mac and it keeps telling me that my device is timed out??? No clue what that means ...Hooked up my old Iphone 4 and it still syncs....Any help would be much appreciated.. Thanks!
-
How to disable booklet 3g jack audio
the sound has gone for the speaker... it is too bad for me, i only can hear the sound by headphone... i already update to the newest audio driver, but still the sound is gone T_T
-
Oracle 9i restore to point in time
We are performing everyday full backups (plus archivelogs) using rman on our Oracle9i RAC database (in archivelog mode). The backup takes around 3 hours to complete. After we start the backup we wait for about 1 hour and then start transacting on the
-
I bought an Iphone 5, opened the App Store, signed up my Apple ID, I confirmed my email address, but when I get back in the App Store, says that not even checked my email, what to do? Help me!