working with XML (find out if element or attribute exists)


/ Published in: PL/SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. CREATE TABLE xtest01(col1 xmltype);
  2. INSERT INTO xtest01 VALUES ('<car><model>Audi TT</model></car>');
  3. INSERT INTO xtest01 VALUES ('<car model="BMW X5"/>');
  4. SELECT x.col1.EXTRACT('//car/model/text()').getstringval() FROM xtest01 x;
  5. SELECT x.col1.EXTRACT('//car/@model').getstringval() FROM xtest01 x;
  6. SELECT * FROM xtest01 x WHERE x.col1.EXISTSNODE('//car') = 1;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.