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

Similar Threads
thread Thread Starter Forum Replies Last Post
Adding the "Explicit" tag to an mp3 file Hustler1337 Digital Audio 0 Apr 6, 2014 12:58 PM
Advanced Search starts with lots of "random" numbers as keywords simsaladimbamba Site and Forum Feedback 6 Feb 18, 2014 10:32 PM
"default.html" file on web server Jaggions Mac OS X Server, Xserve, and Networking 12 Aug 21, 2013 04:51 AM
How to create a pdf file that "compiles" html code and creates hyperlinks? seekinginfo Mac Applications and Mac App Store 0 Aug 7, 2013 02:07 PM
What apps export to "flat HTML"? loft3 Web Design and Development 2 Oct 23, 2012 01:55 PM

Forum Jump

All times are GMT -5. The time now is 10:37 PM.

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

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