Reading XML using JSP
Hi,
My company just bought a software, which this s/w will generate a HTML file with the XML tags and data inside it.
I will need to read the XML tags and data inside the HTML file using JSP.
Does anyone know how to do this?
Please help mi!!Thanks!
http://java.sun.com/webservices/docs/1.1/tutorial/doc/index.html
Similar Messages
-
Hi I want to create a xml using JSP For eg I want to create a report
and I want to take all the data required for the report from the user
and want to put all the information in a session and whenever a user
wants to see the html output I should be able to parse the xml file
and show it to user.
I know it is doable but I am confused about storing the data in
session and concerting that data into XML file any help would be
great.
Thanks,
Preeti
Sounds like you might want to look at XML data binding. Something like JAXB
or Castor can create an object that can be turned into XML by merely calling
a single method and probably streamed to Xalan or whatever to create HTML.
However, don't quote me on this - I am having enough troubles with trying to
get the compiled Objects to be as I wish. Basically, they both take your
DTD with an extra file that defines the types to be used in the classes -
i.e. instead of string int might be used - and which tags to turn into
classes and general information such as this about the output of your
classes. You then simply call Unmarshal (for both castor and JAXB) and it
loads the file from the selected input stream into the created object, you
edit the object, what ever - store it on the server... and call Marshal to
get back the xml... as this is all using streams it could be passed to Xalan
for processing i think...
Hope I've helped, and answered your question a little!
"Preeti Sikri" <[email protected]> wrote in message
news:[email protected]...
> Hi I want to create a xml using JSP For eg I want to create a report
> and I want to take all the data required for the report from the user
> and want to put all the information in a session and whenever a user
> wants to see the html output I should be able to parse the xml file
> and show it to user.
>
> I know it is doable but I am confused about storing the data in
> session and concerting that data into XML file any help would be
> great.
>
> Thanks,
> Preeti
-
How can I use SAX to Read XML in JSP?
I created a class which extend DefaultHandler of SAX. I can use java to call this class and read XML data without any problems. But I can't call this class through JSP. Looks it didn't active startElement() when I called from JSP. Do you have any ideas on this case?
======================This is java call and works==============
import java.io.*;
import java.util.*;
import ReadXmlSax;
public class ReadElement
public static void main(String argv[])
ReadXmlSax r = new ReadXmlSax();
Enumeration e = r.getAttribute("dre.xml","server","name");
try{
while (e.hasMoreElements()) {
System.out.println((String)e.nextElement());}
}catch(Throwable t){
t.printStackTrace();
======================================================================
========================This is jsp call but doesn't work=============
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*" %>
<%@ page import = "ReadXmlSax" %>
<html>
<head><title>SAX Reader</title></head>
<body>
<%
ReadXmlSax r = new ReadXmlSax();
Enumeration e = r.getAttribute("dre.xml","server","name");
while (e.hasMoreElements()) {
out.println(e.nextElement());
out.println("<br>");
%>
</body>
</html>
======================================================================maybe you just simply can't reach dre.xml from your web server!
-
How to send/receive XML using JSP
Hi,
I'm new to all this JSP/XML stuff so apologies if this is trivial.
I'm trying to send an XML file via HTTP POST using JSP. Anyone know how to do this?
Once the XML has been sent, how do you use JSP to request the XML file? I've figured out how to parse it already.
Also, is it possible to call xsql directly within JSP?
Thanks!I'm trying to send an XML file via HTTP POST using JSP. Anyone know how to do this?The question is, does anybody understand what you mean by this. Let me take a guess. You want to upload an XML file to a server. If this guess is right, then the answer is don't use JSP to do that. JSP is for generating output to be sent to a client. Use a servlet to handle an upload. And you don't need to write it yourself, there are already several file-upload servlets available on the web.
Second guess: you have a POST request that asks your server to send an XML file back to the client. If it's a static XML file you don't need a JSP or a servlet or anything, just let your web server handle it just like any other static file. If it's dynamically generated then there's an answer worth giving, but I doubt that this is your question. But if it is, let us know. -
How can I send request to the server through XML using JSP
How can I send XML request to the server using JSP and servlets
Ajax may be the one way.
-
Getting error in Mozilla, reading xml using JavaScript
Hi All,
I am working with javascript with xml, getting error in Mozilla
1. see html and xml file and check xml file path before test ---
2. please, go through the html and xml file.
read_xml.html
=================
<html>
<head>
<title>xml file using javascript</title>
<script type="text/javascript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
//loading xml file
function doLoadXML(xmlFile)
xmlDoc.async="false";
xmlDoc.onreadystatechange=doStateVerify;
xmlDoc.load(xmlFile);
rootData=xmlDoc.documentElement;
function doStateVerify()
if (xmlDoc.readyState != 4)
return false;
// reading xml file
function doReadXML()
alert("calling function");
doLoadXML("C:/Documents and Settings/webdeveloper06/Desktop/for_test/comp-info.xml");
alert("loading file...........");
var dataArr=new Array();
dataArr=xmlDoc.getElementsByTagName("comp-info");
for(var m=0; m <= dataArr.length-1; m++)
alert("entering inside looping here");
document.write("<Table border='1px'><tr><td>");
document.write(dataArr[m].getElementsByTagName("name")[0].firstChild.nodeValue);
document.write(dataArr[m].getElementsByTagName("description")[0].firstChild.nodeValue);
document.write(dataArr[m].getElementsByTagName("web-addr")[0].firstChild.nodeValue);
document.write(dataArr[m].getElementsByTagName("address")[0].firstChild.nodeValue);
document.write(dataArr[m].getElementsByTagName("city")[0].firstChild.nodeValue);
document.write(dataArr[m].getElementsByTagName("postal-code")[0].firstChild.nodeValue);
document.write(dataArr[m].getElementsByTagName("country")[0].firstChild.nodeValue);
document.write("</input></td></tr></table>");
</script>
</head>
<body>
<input type="button" value="Display XML Data" onClick="doReadXML()" />
</body>
</html>
com-info.xml
=========
<?xml version="1.0" encoding="iso-8859-1"?>
<itcopany>
<comp-info>
<name>xxx</name>
<description>IT Reaserch Company</description>
<web-addr>http://xxx.com</web-addr>
<address>mehdipatnam</address>
<city>Hyderabad</city>
<postal-code>777888888</postal-code>
<country>IN</country>
</comp-info>
<comp-info>
<name>yyyyy </name>
<description>Non IT Company</description>
<web-addr>http://yyyy.com</web-addr>
<address>xyxxyxyx</address>
<city>Banglore</city>
<postal-code>78878787878</postal-code>
<country>IN</country>
</comp-info>
<comp-info>
<name>zzzzzzz</name>
<description>IT Company</description>
<web-addr>http://zzzzzzz.com</web-addr>
<address>secondrabad</address>
<city>Hyderabad</city>
<postal-code>9999999999999</postal-code>
<country>IN</country>
</comp-info>
</itcopany>
output status
============
1. getting output in IE
2. not getting output in Mozilla
Can anyone Helpout, To get data in Mozilla
regards,
AbuTry to check this document Browser Support for SAP and use PAM (Product Availability Matrix) to check for the compatibility of your SAP system with the browser.
If you are only the user of the Web Dynpro you would have probably no other choice than change the browser. -
Gurus,
Is it possible to read/write XML using DB Link?
If yes please let me know how to achieve this.
Thanks in Advance.
VenuYou need to use quoted names. SQL Server data dictionary stores names in same case they were entered while Oracle in upper case. So when you issue
Select test.status from testtable@DBLINK test Oracle parser will look for column STATUS while on SQL Server side it could be stored, for examle, as Status or status. Check column names on SQL Server side and use quoted names. Assuming column name is Status:
Select test."Status" from testtable@DBLINK test SY. -
I want to read all <temp >nodes map them to some variable and create one more XML.
I am stuck up in the first place itself where i need to read the data :( . I am getting null pointer exception, please find the code also.
<?xml version="1.0" encoding="UTF-8"?>
<ftpl id="47" name="XXXXXXXX xxx xxxxxxxx">
<abc-cab name="Systems" id="43434">
<abc-dr name="zzzzz" id="4545454">
<temp key="Type">null</param>
<temp key="Folder">/ZVZ/XXXXX - xyz</param>
<temp key="Author">XYZ,ABC</param>
<temp key="Comments">null</param>
<temp key="Mailed_By">XYZ,ABC</param>
<temp key="Subject">null</param>
<temp key="Key_Words">null</param>
<abc-page name="1" id="3524012">
<file text="/asas/asasa/asa/asas/Oxxxxxx2276744.txt" count="1"/>
</abc-page>
</abc-dr>
</abc-cab>
</ftpl>
try {
File file = new File("source-file");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file);
doc.getDocumentElement().normalize();
System.out.println("Root element " + doc.getDocumentElement().getNodeName());
NodeList nodeLst = doc.getElementsByTagName("abc-dr");
for (int s = 0; s < nodeLst.getLength(); s++) {
Node fstNode = nodeLst.item(s);
if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
Element fstElmnt = (Element) fstNode;
NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("abc-dr");
Element fstNmElmnt = (Element) fstNmElmntLst.item(1);
NodeList fstNm = fstNmElmnt.getChildNodes();
System.out.println("First Node : " + ((Node) fstNm.item(1)).getNodeValue());
NodeList lstNmElmntLst = fstElmnt.getElementsByTagName("Folder");
Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
NodeList lstNm = lstNmElmnt.getChildNodes();
} catch (Exception e) {
e.printStackTrace();
Please help.. let me know the code which read XML I have tried with all SAX/DOM i am getting same NUllPointerExcetion
Message was edited by:
JavaNewUserHi
Thanks patricknz
pls find the XMl and the java code
I have again modified the code .. but got the same result as below
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[temp: null]----------------------param =
[abc-page: null]----------------------abc-page=
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
import java.lang.*;
public class SampleDOM
public static void main(String s[]){
try{
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = docBuilder.parse("C:\\demo.xml");
NodeList nodeList = document.getElementsByTagName("abc-dr");
for (int i = 0, length1 = nodeList.getLength(); i < length1; i++) {
final Element rDoc = (Element)nodeList.item(i);
final NodeList rDocC = rDoc.getChildNodes();
for (int j = 0, length2 = rDocC.getLength(); j < length2; j++) {
final Node child = rDocC.item(j);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)child;
System.out.println(element.getChildNodes() + "----------------------" +
new StringBuffer(element.getNodeName()).append(" = "));
}catch(Exception e){
e.printStackTrace();
}XML FIle:-
<?xml version="1.0" encoding="UTF-8"?>
<ftpl id="47" name="XXXXXXXX xxx xxxxxxxx">
<abc-cab name="Systems" id="43434">
<abc-dr name="zzzzz" id="4545454">
<temp key="Type">null</param>
<temp key="Folder">/ZVZ/XXXXX - xyz</param>
<temp key="Author">XYZ,ABC</param>
<temp key="Comments">null</param>
<temp key="Mailed_By">XYZ,ABC</param>
<temp key="Subject">null</param>
<temp key="Key_Words">null</param>
<abc-page name="1" id="3524012">
<file text="/asas/asasa/asa/asas/Oxxxxxx2276744.txt" count="1"/>
</abc-page>
</abc-dr>
</abc-cab>
</ftpl>Message was edited by:
JavaNewUser
Message was edited by:
JavaNewUser -
I am trying to create and send an XML file back to browser where XSL will be
applied. I am using wl6.0 sp2
I tried like this
<%@ page contentType="text/xml" %>
<%
out.println("<?xml version=\"1.0\"?>") ;
out.println("<books>");
out.println("<title>") ;
out.println("XML Programming") ;
out.println("</title>") ;
out.println("</books>") ;
%>
But the browser is blank.
Thanks
shaikjava
Also, valid XML documents have no whitespace before the <?xml ...?>
declaration.
Sam
"Cameron Purdy" <[email protected]> wrote in message
news:[email protected]...
> There are lots of reasons why the browser could be blank. Judging from the
> JSP you provided below, I could not even begin to guess at what you are
> doing to prevent the browser from working.
>
> > <%
> > out.println("<?xml version=\"1.0\"?>") ;
> > out.println("<books>");
> > out.println("<title>") ;
> > out.println("XML Programming") ;
> > out.println("</title>") ;
> > out.println("</books>") ;
> > %>
>
> Do you mean you did all that when you could have just:
>
> <?xml version="1.0"?>
> <books>
> <title>
> XML Programming
> </title>
> </books>
>
> That is what JSPs are for, after all!!! Don't put markup language inside
> code inside a JSP!!! You're going to give someone a friggin heart attack.
>
> Remember:
> servlets = code
> jsps = raw content
>
> You can put content in servlets by embedding it in the code. You can put
> code in jsps by embedding it in the content.
>
> Peace,
>
> --
> Cameron Purdy
> Tangosol Inc.
> << Tangosol Server: How Weblogic applications are customized >>
> << Download now from http://www.tangosol.com/download.jsp >>
>
>
> "chand" <[email protected]> wrote in message
> news:[email protected]...
> > I am trying to create and send an XML file back to browser where XSL
will
> be
> > applied. I am using wl6.0 sp2
> >
> > I tried like this
> >
> > <%@ page contentType="text/xml" %>
> >
> > <%
> > out.println("<?xml version=\"1.0\"?>") ;
> > out.println("<books>");
> > out.println("<title>") ;
> > out.println("XML Programming") ;
> > out.println("</title>") ;
> > out.println("</books>") ;
> > %>
> >
> > But the browser is blank.
> >
> > Thanks
> > shaikjava
> >
> >
> >
> >
> >
> >
> >
>
>
-
XMLDataSet and Dynamic XML using JSP
I am trying to use the XMLDataSet function to call a jsp page
instead of an xml file. The jsp page fetches records out of a db
and creates xml to return to the spry function. Nothing seems to be
returned, and blank spry data region on page.
If i supply a xml file to the function it works correctly.
I adapted the ASP/PHP samples from XMLExport demo. Code as
follows:- If i run 2nd jsp directly, the browser shows the xml as
expected.
--- TEST.JSP ---
<script type="text/javascript">
Spry.Data.Region.debug=true;
var dsPeople = new Spry.Data.XMLDataSet("transtoxml.jsp",
"company/person");
</script>
--- transtoxml.jsp ---
<%@ page language="java"
import="java.sql.*, java.io.*, java.util.*,
com.Ostermiller.util.*"
errorPage="" %>
<%@ include file="globals.jsp" %>
<%
String SQL="";
Statement sTransaction;
ResultSet rTransaction;
try
Class.forName(className);
con =
java.sql.DriverManager.getConnection(connectionURL,userName,password);
}catch(Exception e){
out.print(e.toString());
out.print("Error connecting to database " + connectionURL);
SQL ="SELECT ";
SQL+="[ID], ";
SQL+="[DocumentNo]";
SQL+="FROM TRX_TRANSACTION_MAPPING";
sTransaction = con.createStatement();
try {
rTransaction = sTransaction.executeQuery(SQL);
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("pragma","no-cache");
%>
<?xml version='1.0' encoding='iso-8859-1'?>
<company>
<% while(rTransaction.next()) { %>
<person>
<id><%=(rTransaction.getString("ID"))%></id>
</person>
<% } %>
</company>
<%
response.flushBuffer();
sTransaction.close();
} catch (SQLException e) {
out.print(e);
%>This is the xml output the jsp gives when run directly:- Cut
n pasted from browser. There does appear to be an error, because
the spry:state="error" div is being displayed. If i paste the
following into a file all is ok, any ideas anyone.
regards
sm@rt
<?xml version="1.0" encoding="iso-8859-1" ?>
- <company>
- <person>
<id>117</id>
</person>
- <person>
<id>118</id>
</person>
- <person>
<id>119</id>
</person>
- <person>
<id>120</id>
</person>
- <person>
<id>121</id>
</person>
- <person>
<id>122</id>
</person>
- <person>
<id>123</id>
</person>
- <person>
<id>124</id>
</person>
- <person>
<id>125</id>
</person>
- <person>
<id>126</id>
</person>
- <person>
<id>127</id>
</person>
- <person>
<id>128</id>
</person>
- <person>
<id>129</id>
</person>
- <person>
<id>130</id>
</person>
- <person>
<id>131</id>
</person>
- <person>
<id>132</id>
</person>
- <person>
<id>133</id>
</person>
- <person>
<id>134</id>
</person>
- <person>
<id>135</id>
</person>
- <person>
<id>136</id>
</person>
- <person>
<id>137</id>
</person>
- <person>
<id>138</id>
</person>
- <person>
<id>139</id>
</person>
- <person>
<id>141</id>
</person>
</company> -
Displaying data in xml using jsp
how do we display data in database from jsp using xlst format in xml browser view
how do we display data in database from jsp using xlst
format in xml browser viewRefer this Post
http://forum.java.sun.com/thread.jsp?forum=45&thread=482077&tstart=0&trange=15
-Regards
Manikantan -
Need help with reading XML using File Adapter
I have created a simple BPEL process that uses a file adapter to read files containing XML messages of a simple xsd schema. But when reading the xml, I get the following error message:
[2010/03/01 23:43:13] Invalid data: The value for variable "Receive_1_Read_InputVariable", part "revision-report" does not match the schema definition for this part.The invalid xml document is shown below: More...
[2010/03/01 23:43:13] "{http://schemas.oracle.com/bpel/extension}invalidVariables" has been thrown. less
-<invalidVariables xmlns="http://schemas.oracle.com/bpel/extension">
-<part name="code">
<code>
9710
</code>
</part>
-<part name="summary">
<summary>
Invalid xml document.
According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-complex-type.4: Attribute 'doc' must appear on element 'revision-report'.
Error::cvc-complex-type.4: Attribute 'model' must appear on element 'revision-report'.
Error::cvc-complex-type.4: Attribute 'pubdate' must appear on element 'revision-report'.
Error::cvc-complex-type.2.4.b: The content of element 'revision-report' is not complete. One of '{"http://xmlns.oracle.com/xmlfile":alternategroup}' is expected.
Please make sure that the xml document is valid against your schemas.
</summary>
</part>
</invalidVariables>
It seems that there is some issue with the namespace, but even after trying out various combinations, I am not able to resolve this.
Here the message schema (xsd):
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/xmlfile"
xmlns:tns="http://xmlns.oracle.com/xmlfile"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="revision-report">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="alternategroup">
<xs:complexType>
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="Desc" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="doc" use="required" type="xs:string"/>
<xs:attribute name="model" use="required" type="xs:string"/>
<xs:attribute name="pubdate" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
And here is the xml file to be read by the file adapter:
<?xml version="1.0" encoding="UTF-8" ?>
<revision-report doc="doc2" model="model4" pubdate="pubdate5">
<alternategroup Name="ABC" Desc="ABC-Desc">
</alternategroup>
<alternategroup Name="DEF" Desc="DEF-Desc">
</alternategroup>
<alternategroup Name="GHI" Desc="GHI-Desc">
</alternategroup>
</revision-report>
Appreciate any help.
Thanks in advance for your attention.
JayThanks for your response.
I am not sure if there is any easier way, but I tried out the following tool available on the net to check an xml against a xsd:
http://tools.decisionsoft.com/schemaValidate/
There were a few issues, that I corrected and finally had a xsd and xml that were matching and valid. I tried this out in my file reading BPEL process, but the error still remained the same!
Here is my updated/simplified xsd and xml:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema targetNamespace="http://xmlns.oracle.com/xmlfile"
xmlns:tns="http://xmlns.oracle.com/xmlfile"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://xmlns.oracle.com/xmlfile">
<xs:element name="revision-report">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="alternategroup"/>
</xs:sequence>
<xs:attribute name="doc" use="required" type="xs:string"/>
<xs:attribute name="model" use="required" type="xs:string"/>
<xs:attribute name="pubdate" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="alternategroup">
<xs:complexType>
<xs:attribute name="Name" use="required" type="xs:string"/>
<xs:attribute name="Desc" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8" ?>
<revision-report doc="doc2" model="model4" pubdate="pubdate5" xmlns="http://xmlns.oracle.com/xmlfile">
<alternategroup Name="ABC" Desc="ABC-Desc"/>
<alternategroup Name="DEF" Desc="DEF-Desc"/>
<alternategroup Name="GHI" Desc="GHI-Desc"/>
</revision-report>
I even tried the option that is available in JDeveloper to generate a sample xml from a xsd (when in the context of a Transformation activity). The xml generated by this also seems exactly like the one above.
So, I am not able to figure out why my BPEL process errors out with the message Invalid xml document. -
How to read XML using vbscript
hi friends I have A big XML having following format :
<ECSC>
<ATTRIBUTES>
<ETTOOLNAME>ECATT</ETTOOLNAME>
<ETOBJ_GNDT>
<VERSION>00000001</VERSION>
<TWB_TITLE>TF_FI_FP_FI_0569_MS07_CO_Search_Help_Internal_Orders_vTD0_1_EN.x</TWB_TITLE>
<TWB_STATUS>X</TWB_STATUS>
<TWB_RELE>N</TWB_RELE>
<FUSER>ECATT</FUSER>
<FDATE>2014-05-22</FDATE>
<LUSER>ECATT</LUSER>
<LDATE>2014-05-22</LDATE>
<LTIME>13:59:50</LTIME>
</ETOBJ_GNDT>
<ETOBJNOVER>
<NAME>ZX_FI_FP_0569_MS07_COAS_FB01</NAME>
<TYPE>ECSC</TYPE>
<TWB_RESP>ECATT</TWB_RESP>
<TWB_DISTL>B</TWB_DISTL>
<DEVCLASS>Z_SOL_ONEERP</DEVCLASS>
<MASTERLANG>E</MASTERLANG>
<TADIR_RESP>ECATT</TADIR_RESP>
<FRANGE>BC</FRANGE>
</ETOBJNOVER>
<ETOBJ_DOC>
<SEARCH_1>FI_FP_FI_0569_MS07</SEARCH_1>
<SEARCH_2>COAS</SEARCH_2>
<SEARCH_3>KO03</SEARCH_3>
</ETOBJ_DOC>
<ETOBJ_CNST>
<TWB_WKREQ>0.000</TWB_WKREQ>
<TWB_PRIO>3</TWB_PRIO>
</ETOBJ_CNST>
<ETSC_TSYS>
<SYSTEMDATA>Z_SD_1ERP_Z</SYSTEMDATA>
<TESTSYSTEM>FI_TRUSTED_EN</TESTSYSTEM>
</ETSC_TSYS>
<ETSYS_COMP_TABTYPE/>
<ETSYS_REL_TABTYPE/>
</ATTRIBUTES>
<SCRIPT>
<ETXML_LINE_TABTYPE>
<item>***********************************************************************.</item>
<item>* Information.</item>
<item>**********************************************************************.</item>
<item>* Script for test case 'TF_FI_FP_FI_0569_MS07_CO_Search_Help_Internal_Orders_vTD0_1_EN.x'</item>
<item>*</item>
<item>* For Sub script:</item>
<item>* 'Test case 3: Choose an Internal Order in One.Fi using external order number while transaction posting (positive case)'.</item>
<item>*</item>
<item>* Script is to Display Internal Order using external order number while Transaction Posting 'FB01'</item>
<item>* GETTAB command is being used to fetch the data from table 'COAS'.</item>
<item>*</item>
<item>*</item>
<item>* Test data related Information</item>
<item>* -----------------------------</item>
<item>* Default test data present in parameter list has been used while Scripting ( script recording & Performing Checks ).</item>
<item>*</item>
<item>* Final execution of result log: 0000037077.</item>
<item>*</item>
<item>***********************************************************************.</item>
<item>* Preparation.</item>
<item>***********************************************************************.</item>
<item/>
<item/>
<item>***********************************************************************.</item>
<item>* End Preparation.</item>
<item>************************************************************************.</item>
<item/>
<item/>
<item>***********************************************************************.</item>
<item>* Execution.</item>
<item>***********************************************************************.</item>
<item>* To get the 'Table Entries' from table 'COAS'.</item>
<item> GETTAB ( COAS , COAS_1 ).</item>
<item>* To display the value for the field 'External Order No'.</item>
<item> LOG ( V_EXTERNAL_ORDER_NO_FRM_TABL ).</item>
<item/>
<item>*----------------------Posting(FB01)-------------------------------------------*.</item>
<item/>
<item>* This part of Script is to Display Internal Order using external order number while Transaction Posting 'FB01'.</item>
<item>MESSAGE ( MSG_1 ).</item>
<item>* To get the name of the Title Screen.</item>
<item> GETGUI ( FB01_100_STEP_1 ).</item>
<item>* Enter the Required details and Press Enter.</item>
<item> SAPGUI ( FB01_100_STEP_2 ).</item>
<item>* Enter Amount and Tax Code.</item>
<item>* and, Press F4 help in the Order Field.</item>
<item> SAPGUI ( FB01_300_STEP_1 ).</item>
<item>* In F4 screen, enter the 'External Order Number'</item>
<item>* pop-up screen is displayed with entries like Order, Description and External Order Number and select 1st order row, press Enter.</item>
<item> SAPGUI ( FB01_200_STEP_1 ).</item>
<item>* To get the values for the field 'Order, Description and External Order No' from F4 help.</item>
<item> GETGUI ( FB01_120_STEP_1 ).</item>
<item> SAPGUI ( FB01_120_STEP_3 ).</item>
<item>* To get the value for the field 'Order' from Main screen.</item>
<item> GETGUI ( FB01_300_STEP_2 ).</item>
<item>* click on 'F3' back button.</item>
<item> SAPGUI ( FB01_300_STEP_3 ).</item>
<item>* click on 'F3' back button.</item>
<item> SAPGUI ( FB01_700_STEP_1 ).</item>
<item>* click 'Yes' button.</item>
<item> SAPGUI ( FB01_200_STEP_2 ).</item>
<item>* click on 'F3' back button.</item>
<item> SAPGUI ( FB01_100_STEP_3 ).</item>
<item>ENDMESSAGE ( E_MSG_1 ).</item>
<item/>
<item>* To display the Title Screen.</item>
<item> LOG ( V_TITLE_SCREEN ).</item>
<item>* To display the 'Order' Number from F4 help.</item>
<item> LOG ( V_ORDER_NO_FROM_F4 ).</item>
<item>* To display the 'Description' from F4 help.</item>
<item> LOG ( V_DESCRIPTION_FROM_F4).</item>
<item>* To display the 'External Order no' value from F4 help.</item>
<item> LOG ( V_EXTERNAL_ORDER_NO_FROM_F4 ).</item>
<item>* To display the 'Order' Number from main screen.</item>
<item> LOG ( V_ORDER_NO_FRM_MAIN_SCREEN ).</item>
<item>************************************************************************.</item>
<item>* End Execution.</item>
<item>***********************************************************************.</item>
<item/>
<item>***********************************************************************.</item>
<item>* Check.</item>
<item>***********************************************************************.</item>
<item>* To check name of Title screen for transaction FB01.</item>
<item> CHEVAR ( V_TITLE_SCREEN = I_TITLE_SCREEN ).</item>
<item>* To check the value for the field 'External Order No' from F4 help, which should be equal to 'External Order No' from table.</item>
<item> CHEVAR ( V_EXTERNAL_ORDER_NO_FRM_TABL = V_EXTERNAL_ORDER_NO_FROM_F4 ).</item>
<item>* To check the values for the field 'Order' number from Table, which should be equal to 'Order' no from F4 screen and Main screen.</item>
<item> CHEVAR ( ( I_ORDER_NUMBER_FROM_TABLE = V_ORDER_NO_FROM_F4 ) AND ( I_ORDER_NUMBER_FROM_TABLE = V_ORDER_NO_FRM_MAIN_SCREEN )).</item>
<item>************************************************************************.</item>
<item>* End Check.</item>
<item>************************************************************************.</item>
</ETXML_LINE_TABTYPE>
</SCRIPT>
<PARAMETERS>
<ETPAR_GUIX>
<item>
<PNAME>COAS_1</PNAME>
<PTYP>X</PTYP>
<PDESC>Generated Table for View</PDESC>
<PINDEX>0001</PINDEX>
<PGROUP>GETTAB</PGROUP>
<XMLREF_TYP>T</XMLREF_TYP>
<PSTRUC_TYP>T</PSTRUC_TYP>
<PREF_TYPE>VIEW</PREF_TYPE>
<PREF_NAME>COAS</PREF_NAME>
<PDATLEN>0000</PDATLEN>
<PINTLEN>000000</PINTLEN>
<PDECIMALS>000000</PDECIMALS>
<SORT_LNR>0001</SORT_LNR>
<PREF_NAME2>COAS</PREF_NAME2>
<VALUE><VALUE></VALUE>
<VAL_TYPE>T</VAL_TYPE>
<TAB_INDEX>0</TAB_INDEX>
</item>
<item>
<PNAME>IOAS_1</PNAME>
<PTYP>I</PTYP>
<PDESC>Generated Table for View</PDESC>
<PINDEX>0001</PINDEX>
<PGROUP>IETTAB</PGROUP>
<XMLREF_TYP>T</XMLREF_TYP>
<PSTRUC_TYP>T</PSTRUC_TYP>
<PREF_TYPE>VIEW</PREF_TYPE>
<PREF_NAME>COAS</PREF_NAME>
<PDATLEN>0000</PDATLEN>
<PINTLEN>000000</PINTLEN>
<PDECIMALS>000000</PDECIMALS>
<SORT_LNR>0001</SORT_LNR>
<PREF_NAME2>COAS</PREF_NAME2>
<VALUE><VALUE></VALUE>
<VAL_TYPE>T</VAL_TYPE>
<TAB_INDEX>0</TAB_INDEX>
</item>
</ETPAR_GUIX>
</PARAMETERS>
</ECSC>
I want to write vbscript for above XML file. Vbscript should display following result :
1) It should validate <SCRIPT> node The line staring with * symbol is called comment and the line staring without * symbol is call code in above XML file.
2) Vb Script should display such line numbers those code don't have any comment line specified.
for example : In above XML the code line : <item> SAPGUI ( FB01_120_STEP_3 ).</item> it doesn't have any comment line means this code don't have any comment. So vbscript should find such line numbers and code text and show error message.
3) Each code had its own comment just above line of code.
4) In <PARAMETER> node we have to check <PNAME> is staring with letter "I" or not.. If its staring with letter "I" then its <PTYPE> and <PGROUP> staring letter should be "I". We have to check this condition
for every child node of <PARAMETER> node using vbscript.
Please help me and Thank You so much in advance.
My Vb Script is as follows :
filename = "D:\Automation\o.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filename)
fl=0
Do Until f.AtEndOfStream
strLine = f.ReadLine
if (strLine ="MESSAGE ( MSG_1 ).") then
Document.write("<br>Inside MESSAGE ")
Do until f.AtEndOfStream
strLine = f.ReadLine
if((Left(strLine,1)="*"))
Then
if((Right(strLine,1)="."))
then
Document.write("<br>ERROR Found at Line No :" & f.line-1&" "& strLine)
end if
fl=1
else
if((Right(strLine,1)=".")
and (fl=1))Then
fl=0
else
Document.write("<br>ERROR Found at Line No :" & f.line-1&" "& strLine)
end if
end if
Loop
end if
And the following code for <PARAMETER> tag :
Const XMLDataFile = "D:\Automation\imp\p.xml"
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
xmlDoc.Load(XMLDataFile)
xmlDoc.validateOnParse = True
If xmlDoc.Load(XMLDataFile) Then
Document.write "SUCCESS loading XML File"
Else
Document.write "ERROR loading XML File"
End If
counter=0
Set root = xmlDoc.documentElement
Set items = root.childNodes
for each item in items
myPNAME = xmlDoc.getElementsByTagName("PNAME").item(counter).text
myPTYP = xmlDoc.getElementsByTagName("PTYP").item(counter).text
myPGROUP = xmlDoc.getElementsByTagName("PGROUP").item(counter).text
If (Left(myPNAME, 1) = "I") Then
'Document.write("myPNAME Starts with I")
IsValid = True
'Innocent until proven guilty
If (Left(myPTYP, 1) <> "I") Then
IsValid = False
End If
If (Left(myPGROUP, 1) <> "I" )Then
IsValid = False
End If
If IsValid = False Then
Document.write(myPNAME & " is not valid.")
End If
IsValid = True
End If
If (Left(myPNAME, 1) = "V") Then
'Document.write("myPNAME Starts with I")
IsValid = True
'Innocent until proven guilty
If (Left(myPTYP, 1) <> "V") Then
IsValid = False
End If
If (Left(myPGROUP, 1) <> "V" )Then
IsValid = False
End If
If IsValid = False Then
Document.write(myPNAME & " is not valid.")
End If
IsValid = True
End If
If (Left(myPNAME, 1) = "E") Then
'Document.write("myPNAME Starts with I")
IsValid = True
'Innocent until proven guilty
If (Left(myPTYP, 1) <> "E") Then
IsValid = False
End If
If (Left(myPGROUP, 1) <> "E" )Then
IsValid = False
End If
If IsValid = False Then
Document.write(myPNAME & " is not valid.")
End If
IsValid = True
End If
counter=counter+1
next
Here is a better example of how to pull all of the text.
strXmlFile = "D:\Automation\imp\p.xml"
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
If xmlDoc.Load(strXmlFile) Then
WScript.Echo "SUCCESS loading XML File"
Else
WScript.Echo "ERROR loading XML File"
End If
Set items = xmlDoc.SelectNodes("//SCRIPT/ETXML_LINE_TABTYPE/item")
For Each item In items
WScript.Echo item.Text
Next
¯\_(ツ)_/¯ -
Hi ALL,
I have a xml as follows:
<AAA>
<BBB>
<CCC>xyz</CCC>
<DDD>abc</DDD>
</BBB>
</AAA>
Now using any of the java class, i just need read the value of "CCC" as follows:
(i.e using xpath i need to read the value)
String val = x.somemethod("/AAA/BBB/CCC");
Thanks!In case you're curious - here's the dom4j equivalent of dvohra09's sample code.
SAXReader saxReader = new SAXReader("org.apache.xerces.parsers.SAXParser");
Document doc = saxReader.read(source); //Where source is your file, input source, input stream, reader, or url
String value = doc.valueOf("//AAA/BBB/CCC"); //Result given the xml from OP = 'xyz'OK - not much difference with this simple example but if you haven't settled on an API, dom4j is worth looking at (IMHO).
∞ brewman ∞ -
I am trying to create and send an XML file back to browser where XSL will be
applied. I am using wl6.0 sp2
I tried like this
<%@ page contentType="text/xml" %>
<%
out.println("<?xml version=\"1.0\"?>") ;
out.println("<books>");
out.println("<title>") ;
out.println("XML Programming") ;
out.println("</title>") ;
out.println("</books>") ;
%>
But the browser is blank.
Thanks
shaikjavaYou haven't provided adequate relevant information. If you need help provide proper relevant details.
Maybe you are looking for
-
Hi everyone! I need to execute some instructions when user exit from the program. Something like AT EXIT-COMMAND in PAI. But i dont have any PAI module or declared flow logic in my screen definition, becouse screen is calling automaticly by abap, i c
-
File to JDBC :Error when executing statement for table/stored proc.
Hi, I am getting following error when i am trying to insert data into z-table using JDBC recr adapter. Error while parsing or executing XML-SQL document: Error processing request in sax parser: Error when executing statement for table/stored proc. 'Z
-
InDesign CS6 resolution for pixel documents not the same
I have just opened in InDesign CS6, a document made originaly in CS5.5. This document is in pixels. At 100%, the document should be pixel for pixel with my monitor (iMac 27" at about 104 ppi), but it seems it is more at 100% if you calculate at 72 pp
-
Administrative Timesheet Classes and TS_LINE_CLASS_ORGANIZATION
Hi! I'm bulk-creating lots of admin timesheet classes (yes, I know that there's no supported way of removing such classes after creating them, but still...) When creating such a line class, there's a field TS_LINE_CLASS_ORGANIZATION that's used in so
-
Help with copying contacts from iPad to Pc.
Until recently, my contacts, emails and calenders were synced between my iPhone4, iPad 2 and my work laptop via MS Exchange. I have now left the company, and all my contacs have gone from my phone becasue i removed the work email address. The contact