How to check the element in xml file by xpath
hi all,
* How to check the element in xml file by xpath
for the following XML file,
* I want to check whether
the element (sage) is present or not in the following xml file XPATH expression...
* I have tried by the following expression ,
NodeList result = (NodeList) xpath.evaluate("//*:student/*:sage/text()",xml_dom,XPathConstants.STRING);
System.out.println(result.item(0).getLocalName()); * I want to get the Element sage as String value....
but i am not able to get the element,why that ??? and How to do that ???
MyXML File :
<x:student>
<x:sname>aaa</x:sname>
<x:sage>26</x:sage>
</x:student>
Thanks,
JavaImran
<code>* Thanks for reply....
* </code><code>In </code>
<code>x:student element x represents the namespace...thats why i put *:student in my expression....
"//*[local-name() = 'student']/*[local-name() = 'sage']/text()"* By the above code , i am not able to get the sage as string from
</code> resul.item(0).getLocalName() method.......?
* How to get that as string format ?
Similar Messages
-
How to update the value in xml file using transformer after setNodeValue
Hi,
This is my code
I want to set update the values in xml file using transformer..
Any one can help me
This is my Xml file
<?xml version="1.0" encoding="UTF-8"?>
<place>
<name>chennai</name>
</place>
Jsp Page
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="javax.xml.parsers.DocumentBuilderFactory,
javax.xml.parsers.DocumentBuilder,org.w3c.dom.*,org.w3c.dom.Element"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<% String str="";
String str1="";
try
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse("http://localhost:8084/XmlApplication1/sss.xml");
out.println("Before change");
NodeList n11 = doc.getElementsByTagName("name");
Node n22= n11.item(0).getFirstChild();
str1 = n22.getNodeValue();
out.println(str1);
out.println("After change");
String name = "Banglore";
NodeList nlst = doc.getElementsByTagName("name");
Node node= nlst.item(0).getFirstChild();
node.setNodeValue(name);
NodeList n1 = doc.getElementsByTagName("name");
Node n2= n1.item(0).getFirstChild();
str = n2.getNodeValue();
out.println(str);
catch(Exception e)
out.println(e) ;
%>
<h1><%=str%></h1>
<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>
</body>
</html>hi check this exit...
IWO10012 -
How to read the contents of XML file from my java code
All,
I created an rtf report for one of my EBS reports. Now I want to email this report to several people. Using Tim's blog I implemented the email part. I am sending emails to myself based on the USERID logic.
However I want to email to different people other then me. My email addresses are in the XML file.
From the java program which sends the email, how can I read the fields from XML file. If any one has done this, Please point me to the right examples.
Please let me know if there are any exmaples/BLOG's which explain how to do this(basically read the contents of XML file in the Java program).
Thank You,
PadmaIke,
Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
Please help me.
Thank you for your posting.
Padma. -
How to send the dynamically generated XML file to other site for further processing?
I have a question regarding exchanging data between two systems
using XSQL servlet. The situation is descrbed as the follows:
Assume that we have a simple XSQL page named "emp.xsql"
<?xml version="1.0"?>
<?-- XSQL page file "emp.xsql" -->
<xsql:query xmlns:xsql="urn:oracle-xsql" connection="demo" >
SELECT * FROM EMP
</xsql:query>
and we can access it through the HTTP request likes
http://web_server_name/xsql/emp.xsql.
Usually we will the returned dynamic XML file and show it on the
screen. Now the problem is that we don't want to show the
generated XML file on the calling screen. Instead, we want to
send the generated XML file to other website for further
processing, say, using JSP or ASP likes
http://other_web_server_name/XMLProcessing.jsp?.....
How can it be implemented using XSQL servlet?
Any hint and outline of the solution is appreciated.
ThanksIke,
Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
Please help me.
Thank you for your posting.
Padma. -
How to check the contents of Control file, Log file & Parameter file
Can anybody help me how i can check the contents of Control file, Log file & Parameter file.
ArifOK ...
Parameter file:
It will normally be in the $ORACLE_HOME/dbs directopry. It could be aan init{sid}.ora or a spfile{sid}.ora ... do not edit an SPFILE as yu could corrupt it.
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14231/create.htm#sthref434
If it's an init{sid}.ora, use any editor to see the actual content.
If it's a spfile{sid}.ora, use one of V$PARAMETER, V$PARAMETER2, V$SYSTEM_PARAMETER, V$SYSTEM_PARAMETER2 as aappropriate (read the Reference manual to get an idea about when each is appropriate)
Control File:
You should not edit a control file. It consists of many areas, as described here http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14220/physical.htm#i10135 and each are is interrogated by V$views as given in the reference manual. The following V$views all deal with some aspect of the control file or provide info about the control files or the contents of control files:
V$ARCHIVE_DEST
V$ARCHIVED_LOG
V$BACKUP_ARCHIVELOG_DETAILS
V$BACKUP_CONTROLFILE_DETAILS
V$BACKUP_CONTROLFILE_SUMMARY
V$BACKUP_COPY_DETAILS
V$BACKUP_COPY_SUMMARY
V$BACKUP_CORRUPTION
V$BACKUP_DATAFILE
V$BACKUP_DATAFILE_DETAILS
V$BACKUP_FILES
V$BACKUP_PIECE
V$BACKUP_REDOLOG
V$BACKUP_SET
V$BACKUP_SET_DETAILS
V$BACKUP_SPFILE
V$CONTROLFILE
V$CONTROLFILE_RECORD_SECTION
V$COPY_CORRUPTION
V$DATABASE
V$DATABASE_INCARNATION
V$DATAFILE
V$DATAFILE_COPY
V$DATAFILE_HEADER
V$DELETED_OBJECT
V$LOCK
V$LOG
V$LOG_HISTORY
V$LOGHIST
V$OBSOLETE_BACKUP_FILES
V$OFFLINE_RANGE
V$PROXY_COPY_DETAILS
V$PROXY_COPY_SUMMARY
V$PROXY_DATAFILE
V$RMAN_BACKUP_JOB_DETAILS
V$RMAN_BACKUP_SUBJOB_DETAILS
V$RMAN_CONFIGURATION
V$SESSION
V$TABLESPACE
V$THREAD
V$UNUSABLE_BACKUPFILE_DETAILS
3) Log Files
The contents of the log files are viewed using LogMiner - read Chapter 11 of the Oracle Utilities manual -
How to add attribute to the elements in XML file in BPEL transformation
Hi All-
I have to create a XML file using transformation and file adapater and the parent element is USERRECORDS, now when I am creating the XML file using transformation the XML get creates like
<?xml version="1.0">
<USERRECORDS>
so on
But I want the parent element and the xml version tags as:
<?xml version="1.0" encoding="UTF-8"?>
<USERRECORDS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mySchema.xsd">
as I need to add the attributes.
Is it possible in transformation?
Any idea, please suggest.
Thanks and Regards,
SreejitI have never come across any functionality like that.
However I assigned values to attributes in Assign Acitivity using XML Fragment on source side. -
Hi all,
I learmed the basic stuff of XML, DTD, DOM, etc. long time ago. Now, I came back to resume my XML journey and try to learn the XML Schemas, XPath and XQuery. I have Microsoft SQL Server 2012 Management Studio (SSMS2012) in our computer network. From
Page 221 of the old Book "Beginning XML 2nd Edition" written by David Hunter, et.al., (published by Wrox), I copied the name5.xsd and name5.xml :
<?xml version="1.0"?>
<schema xmlns=http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.wrox.com/name" xmlns:target="http://www.wrox.com/name"
elementFormDefault="qualified">
<element name="name">
<complexType>
<sequence>
<element name="first" type="string"/>
<element name="middle" type="string"/>
<element name="last" type="string"/>
</sequence>
</complexType>
</element>
</schema>
<?xml version="1.0"?>
<name
xmlns=http://www.wrox.com/name"
xmlns:xsi="http://www.wrox.org/2001XMLSchema-instance"
xsi:schemaLocation="http://www.wrox.com/name name5.xsd"
title="Mr.">
<first>John</first>
<middle>Frizgerald</middle>
<last>Doe</last>
</name>
How can I execute these two files in my SSMS2012 for doing my first XML Schema trial?
Please kindly help, advise and respond.
Thanks in advance,
Scott ChangHi Eric Zhang, Thanks for your nice response.
1) I saw the CREATE XML SCHEMA COLLECTION (Transact-SQL) and tried its first example "Create XML schema collection in the database" in my SQL Server 2012 Management Studio (SSMS2012):
-- Create a sample database in which to load the XML schema collection.
-- Copied this set of code stsments from Microsoft Library (ms176009)
-- ColesMS12_20a.sql (saved in C:/Documents/SQL Server Management Studio)
-- 19 March 2015 1145 AM
CREATE DATABASE SampleDB
GO
USE SampleDB
GO
CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS
N'<?xml version="1.0" encoding="UTF-16"?>
<xsd:schema targetNamespace="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
xmlns ="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:complexType name="StepType" mixed="true" >
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
<xsd:element name="tool" type="xsd:string" />
<xsd:element name="material" type="xsd:string" />
<xsd:element name="blueprint" type="xsd:string" />
<xsd:element name="specs" type="xsd:string" />
<xsd:element name="diag" type="xsd:string" />
</xsd:choice>
</xsd:complexType>
<xsd:element name="root">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="Location" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="step" type="StepType" minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="LocationID" type="xsd:integer" use="required"/>
<xsd:attribute name="SetupHours" type="xsd:decimal" use="optional"/>
<xsd:attribute name="MachineHours" type="xsd:decimal" use="optional"/>
<xsd:attribute name="LaborHours" type="xsd:decimal" use="optional"/>
<xsd:attribute name="LotSize" type="xsd:decimal" use="optional"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>' ;
GO
-- Verify - list of collections in the database.
select *
from sys.xml_schema_collections
-- Verify - list of namespaces in the database.
select name
from sys.xml_schema_namespaces
-- Use it. Create a typed xml variable. Note collection name specified.
DECLARE @x xml (ManuInstructionsSchemaCollection)
GO
--Or create a typed xml column.
CREATE TABLE T (
i int primary key,
x xml (ManuInstructionsSchemaCollection))
GO
-- ////The following code statements are not used in order to create SampleDB
-- Clean up
---DROP TABLE T
---GO
---DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
---Go
---USE Master
---GO
---DROP DATABASE SampleDB
It worked and I got the following results:
1 4 NULL sys 2009-04-13 12:59:13.390 2012-02-10 20:16:02.097
65536 1 NULL ManuInstructionsSchemaCollection 2015-03-19 11:47:17.660 2015-03-19 11:47:17.660
http://www.w3.org/2001/XMLSchema
http://schemas.microsoft.com/sqlserver/2004/sqltypes
http://www.w3.org/XML/1998/namespace
http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions
But, I don't undertand (i) what SCHEMA COECTION is, (ii) what <xsd:schema targetNamespace=.....</xsd:complexType> are, (iii) How I can specify my "project specific" schema in the Microsoft SCHEMA COLLECTION to check my xml file.
2) I dived in the XQuery programmimng in SSMS2012 in the last few weeks. I used the examles of Ad-Hoc XML File Query by Seth Delconte (in
httpS://www.simple-talk.com/content/print.aspx?article=1756) in my SSMS2012. They worked. But I don't understand the (i) Importing XML data using a function, (ii) Using the XQuery contans()
function to find substrings, (iii)Efficiency comparisons in the article.
Please kindly help me in enlightening me to resolve the difficulties listed in 1) and 2).
Thanks,
Scott Chang -
How to check the type of uploaded file
Hi, experts,
how can I check the type of the uploaded file? I am dealing with exception handling now: when user uploads a type of file which is not allowed, then error msg shows up. So first I have to retrieve the type of the uploaded file.
Best regards,
FanBest approach would be to control the file upload program. Here in force user to chose only the kind of file supported.
If you are using WD4A & fileupload UI element, then after user select a file to upload, before processing the file you can check the file name and get its MIME TYPE as shown below.
example
data type file string.
data dot_offset type i.
data extension type mimetypes-extension.
data mimetype type mimetypes-type.
file = 'Image.jpg'.
" Find out file name extension
find first occurrence of regex '\.[^\.]+$' in file match offset dot_offset.
add 1 to dot_offset.
extension = file+dot_offset.
" Get mime type
call function 'SDOK_MIMETYPE_GET'
exporting
extension = extension
importing
mimetype = mimetype.
later using if/else or CASE statement define your logic.
Greetings
Prashant
P.S. Points Welcome -
How to get the values from xml file to java combo box
Hi frens,
I am new to java and xml programming,
Now, i want to have a code of getting the tag values from the xml file
into the swing combo box of java front end.
How can we do that?
any help of code or tutorial or an ebook is a great help for me.
Thank you,
Karthik.
Edited by: Karthik84 on Aug 27, 2008 1:49 AM
Edited by: Karthik84 on Aug 27, 2008 11:29 PMlook at this link
http://www.stylusstudio.com/docs/v2006/d_help30.html
I read sometime back that castor has a tool to do
conversion. You might have a look into casto as well. -
How to display the data in XML files into JSP using Jdeveloper.
Hi All,
I have two XML files one XML file has the view names and the other has the table names of a particular views, how to display the data in JSP using JDeveloper where when i click a particular view the list of tables of that particular view from XML file two should be displayed in JSP Page.
Are there any reference documents, regarding the above process please can anyone guide through how to do it.Let the servlet ask your business tier to provide the data, then stuff it into beans, and pack those into the Session instance. Then forward the request to the JSP, let the JSP get those beans and display them.
-
How to read the data from XML file and insert into oracle DB
Hi All,
I have below require ment.
I will receive data in the XML file. then i need to read that data and insert into oracle tables. please let me know how this can be handled.
Many Thanks.Sounds a lot like this question, only with less details.
how to read data from XML variable and insert into table variable
We can only help if you provide us details to help as we cannot see what you are doing and only know what you tell us. Plenty of examples abound on the forums that cover the topics you seek as well. -
How to make the tags in XML file case insensitive
Hi,
I have a ReadXML class which reads an xml file. This class also has a method which receives a string-child from another class and uses this string-chile to match it with the child tag in the xml file, and returns the child tag's value.
Now, my problem is this, the child tag in xml may be in a case different from the case of the string-child received from another class.
How do I modify it, so the program does not return a null pointer exception because the strings did not match for want of uppercase or lowercase letters.
Thanks
SangeethaI'm not sure what you are getting at. Is a string child the contents of a node treated as text?
If you are trying to match a child node regardless of case I doubt this is possible as the XML standard says an XML document is case sensitive so if your parser ignored case it would not be XML complient.
Hope this helps. -
How to read the attributes of XML file
Hi this is ant,
I am new to java, XML, I have a senario
1) I have to read all the href attributes for topicref child, and then read the corresponding xml file which is mapped in href="".
First.xml
<map>
<topicref nav="garage" href="task/gar/view.xml" class="..">
<linktext class="_map/linktext">Garage</linktext>
<topicref nav="" href="task/gar/change.xml" ..>
<linktext class="_map/linktext">Garage</linktext>
</topicref>
</linktext>
</topicref>
</map>
2) task/gar/view.xml file , has id attribute & need to get the id values.
Like this I have to get the id values for all the href attributes of first xml & read correspoding id values.
I have just read some doc using XPATH we can do, please help me.
Thanks.
anto* Try this Link, there is solution
http://forums.sun.com/thread.jspa?messageID=9665228
Can...Can...If we try...! -
How to check the existence of a file?
Hi,
I want to know how to use FileNotFoundException to check whether a text file exists in local directory.
How should I do the code?
Thanks
gogoLike this:
private File f = new File ("c:\\projects\\sutil\\err\\temp_err.txt");
if (f.exists()) {
f.delete();
} -
How to upload the data from XML file to SAP database using IDOC
Hi,
I need some steps to upload data from XML format file from other directory to SAP database using IDOC.
how to approch this please if any one knows give me ans
it will be a great help ful to me
Thanks in Advance
MallikThank you vijay,
But i heard that by using this Fun modules, when we are passing IDOC in back ground schedule, so some other depended FM not supporting, so how to approach this and how to avoid this problem.
Have you worked on this before if any one worked on this please help me out
And thank you once again for your valuable information
Best Regards
Mallik
Maybe you are looking for
-
Warning message in LI11N transaction
Warning message "Material flagged for deletion" does not appear in the transaction LI11N - Enter inventory count - for materials flagged for deletion. Tried searching SAP notes but couldnt find. Checked in 4.7, ERP 5 and ERP 6 releases but in all sys
-
Hi All, I am trying to work with DBMS_JOB.SUBMIT and i am unable to move forward since i am not understanding where i am wrong. Please help me with my issue. I have a package as below CREATE OR REPLACE PACKAGE Pack.main AS PROCEDURE Proc1( V1_P1_in i
-
Apple TV 3rd Generation can't finish loading libraries
I recently moved my iPhoto & iTunes libraries to a new external hard drive. Both work fine from my iMac (iTunes & iPhoto) but when selecting Computers from my Apple TV, the loading of those libraries never finishes. Any thoughts as to why? It worked
-
I removed from my computer macbook, mac app store, and now I want to reinstall with "software update" but doesn´t appareance
-
Hi, we are running wle 5.1/java 1.2 on NT 4.0 Server, we constantly get Dr Watson Error with java.exe when we access our JSP/Servlet pages. has anybody encountered this and what is your suggestion? thanks Girish