Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 7, 2011, 08:38 AM   #1
saleh.hi.62
macrumors member
 
Join Date: Jul 2011
how to export ''Keywords" , "Description" tag in HTML file using LIbXml?

hello guys,

how to export ''Keywords" , "Description" tag in HTML file using LIbXml?

i tried this:

Code:
/html/head/meta/keywords
it's not correct ! how can i do it correctly?
saleh.hi.62 is offline   -1 Reply With Quote
Old Dec 7, 2011, 02:03 PM   #2
MasConejos
macrumors regular
 
Join Date: Jun 2007
Location: Houston, TX
Send a message via ICQ to MasConejos
For keywords, assuming you want the text in the content attribute:
Code:
/html/head/meta[@name="keywords"]/@content
For description:
Code:
/html/head/meta[@name="description"]/@content
Keep in mind that the html you are trying to parse/query needs to be xml compliant. Also be aware that xml is case sensitive, so if the html document uses a different case (i.e. <META/> or <meta name="KEYWORDS"/>, etc). then this xpath expression wont work.

You may be better off using DOM or regular expressions, depending on what you want
MasConejos is offline   1 Reply With Quote
Old Dec 7, 2011, 08:08 PM   #3
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
Let me reiterate. Go through the XPath tutorial here. http://www.w3schools.com/xpath/. You can't just stab in the dark and expect to get very far.
jiminaus is offline   2 Reply With Quote
Old Dec 7, 2011, 08:54 PM   #4
saleh.hi.62
Thread Starter
macrumors member
 
Join Date: Jul 2011
Quote:
Originally Posted by MasConejos View Post
For keywords, assuming you want the text in the content attribute:
Code:
/html/head/meta[@name="keywords"]/@content
For description:
Code:
/html/head/meta[@name="description"]/@content
Keep in mind that the html you are trying to parse/query needs to be xml compliant. Also be aware that xml is case sensitive, so if the html document uses a different case (i.e. <META/> or <meta name="KEYWORDS"/>, etc). then this xpath expression wont work.

You may be better off using DOM or regular expressions, depending on what you want
thank you so much, i have read that tutorial, but its not something very practical and illuminated. !
saleh.hi.62 is offline   -1 Reply With Quote
Old Dec 8, 2011, 12:37 AM   #5
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
Quote:
Originally Posted by saleh.hi.62 View Post
i have read that tutorial, but its not something very practical and illuminated. !
So this example of the tutorial wasn't illuminating?
Quote:
//title[@lang='eng']

Selects all the title elements that have an attribute named lang with a value of 'eng'
You didn't go "Well that's pretty much what I want except I want meta elements that have an attribute named name with a value of description. The forumula seems to be //element[@attribute='value'], perhaps I'll give //meta[@name='description'] a go'. You really didn't run that thought?! Oh, wait, of course you didn't. I seem to have forgotten whose post it is I'm reply to.
jiminaus is offline   2 Reply With Quote
Old Dec 8, 2011, 06:36 AM   #6
saleh.hi.62
Thread Starter
macrumors member
 
Join Date: Jul 2011
Quote:
Originally Posted by jiminaus View Post
So this example of the tutorial wasn't illuminating?


You didn't go "Well that's pretty much what I want except I want meta elements that have an attribute named name with a value of description. The forumula seems to be //element[@attribute='value'], perhaps I'll give //meta[@name='description'] a go'. You really didn't run that thought?! Oh, wait, of course you didn't. I seem to have forgotten whose post it is I'm reply to.
yes you are right, i was not checking carefully.
saleh.hi.62 is offline   -1 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How to convince my parents to let me buy a 17" MacBook Pro Ulf1103 Buying Tips and Advice 58 Nov 27, 2013 11:45 AM
Tutorial: How to get PCSX2 to run on Mac (without BootCamp) Mirrors Mac Applications and Mac App Store 22 Jun 14, 2013 08:19 PM
Does anybody know how to get TweetTask? xmelissaxmayhem Jailbreaks and iOS Hacks 3 Jul 3, 2011 01:21 AM
[HOW TO] DIY iPhone 4 Swivel Car Mount QuarterSwede iPhone Accessories 13 Mar 8, 2011 02:51 PM
How to set text right aligned in NSTextField while using setAttributedStringValue Monaj Mac Programming 2 Oct 27, 2009 11:20 PM


All times are GMT -5. The time now is 12:19 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC