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

Discussion in 'Mac Programming' started by saleh.hi.62, Dec 7, 2011.

  1. macrumors member

    Joined:
    Jul 25, 2011
    #1
    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?
     
  2. macrumors regular

    Joined:
    Jun 25, 2007
    Location:
    Houston, TX
    #2
    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
     
  3. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #3
  4. thread starter macrumors member

    Joined:
    Jul 25, 2011
    #4
    thank you so much, i have read that tutorial, but its not something very practical and illuminated. !
     
  5. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #5
    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.
     
  6. thread starter macrumors member

    Joined:
    Jul 25, 2011
    #6
    yes you are right, i was not checking carefully.
     

Share This Page