Thread: Xml Regex

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Xml Regex


    I confess i am total noob here so if i am going out of line here, please let me know, I won't mind at all... i have this XML file where I need to replace an XML statement with simple text.. problem is I cant seem to figure out the regex for that particular syntax and its already been longer then I anticipated.. the text is in the format

    Code:
    {{</w:t></w:r><w:proofErr w:type="spellStart"/><w:r w:rsidR="003962A4"><w:rPr><w:rFonts w:cs="Arial"/><w:b/><w:bCs/><w:color w:val="000000"/></w:rPr><w:t>claimant_full_name</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r w:rsidR="003962A4"><w:rPr><w:rFonts w:cs="Arial"/><w:b/><w:bCs/><w:color w:val="000000"/></w:rPr><w:t>}}
    Thank you very much in advance...

    Warm Regards
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,111
    Rep Power
    9398
    And what's in the XML file and what part of it are you trying to replace?
    And can you do something with an XML parser or even XSLT?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0
    It is actually a xml file generated by word document. I am not aware of any free parsing library available for docx in php.. let me know if you came across any .. mucho gracias..
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    you don't need a special parser for docx, a generic XML parser works just as good (because it is standard XML after all).

    I don't remember the exact structure of docx, but I think all you have to do is collect the text nodes. In SimpleXML, this is done by casting an element to a string.

IMN logo majestic logo threadwatch logo seochat tools logo