xml data to html table with <ROW> tag data not displayed [message #560070] |
Tue, 10 July 2012 06:32 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/826158e33a8ea114b8fe2bcec7628406?s=64&d=mm&r=g) |
nischalinn
Messages: 118 Registered: May 2012 Location: nepal
|
Senior Member |
|
|
I've generated XML from oracle:
select dbms_xmlquery.getxml('select * from tbl_nm') from dual
<?xml version="1.0" encoding="ISO-8859-1"?>
<ROWSET>
<ROW num="1">
<NAME>admin</NAME>
<PASSWORD>a</PASSWORD>
</ROW>
<ROW num="2">
<NAME>user</NAME>
<PASSWORD>u</PASSWORD>
</ROW>
</ROWSET>
i tried to get this xml data in html table but the table was not displayed. When I changed the <ROW> tag into any other tag say <CD> the table was displayed. Why is it so???
|
|
|
|
|
|
|
|
Re: xml data to html table with <ROW> tag data not displayed [message #560178 is a reply to message #560149] |
Wed, 11 July 2012 01:56 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/102589.gif) |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
This name is fixed by the function, you can use REPLACE to change it.
Or you can build the XML yourself using the xml functions like the xmlelement one you used in your previous topic.
Quote: I've checked all my previous posts.
Yes but you didn't feedback.
For instance, in this one, you didn't tell what actually was the problem and how you solved it, so a future readers with the same problem will not know the solution or how to investigate on it.
Regards
Michel
[Updated on: Wed, 11 July 2012 03:22] Report message to a moderator
|
|
|
|
|
Re: xml data to html table with <ROW> tag data not displayed [message #560197 is a reply to message #560149] |
Wed, 11 July 2012 03:54 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/102589.gif) |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
For instance, from:
SQL> select dbms_xmlquery.getxml('select empno, ename from emp where rownum<=3') res
2 from dual
3 /
RES
------------------------------------------------------------------------------------
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
</ROW>
<ROW num="2">
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
</ROW>
<ROW num="3">
<EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME>
</ROW>
</ROWSET>
With replace:
SQL> select replace(
2 replace(
3 replace(
4 replace(dbms_xmlquery.getxml(
5 'select empno, ename from emp where rownum<=3'),
6 '<ROWSET>', '<EMPLOYEES>'),
7 '</ROWSET>', '</EMPLOYEES>'),
8 'ROW num=', 'EMPLOYEE num='),
9 '</ROW>', '</EMPLOYEE>') res
10 from dual
11 /
RES
----------------------------------------------------------------------------
<?xml version = '1.0'?>
<EMPLOYEES>
<EMPLOYEE num="1">
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
</EMPLOYEE>
<EMPLOYEE num="2">
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
</EMPLOYEE>
<EMPLOYEE num="3">
<EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME>
</EMPLOYEE>
</EMPLOYEES>
1 row selected.
Building the xml:
SQL> set lines 80
SQL> select xmlelement("EMPLOYEES",
2 xmlagg(xmlelement("EMPLOYEE",
3 xmlforest(empno, ename)))) res
4 from emp
5 where rownum <= 3
6 /
RES
--------------------------------------------------------------------------------
<EMPLOYEES><EMPLOYEE><EMPNO>7369</EMPNO><ENAME>SMITH</ENAME></EMPLOYEE><EMPLOYEE
><EMPNO>7499</EMPNO><ENAME>ALLEN</ENAME></EMPLOYEE><EMPLOYEE><EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME></EMPLOYEE></EMPLOYEES>
1 row selected.
Regards
Michel
|
|
|
|