Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

xml and CR LF

Last post 06-16-2008, 2:28 AM by mash. 2 replies.
Sort Posts: Previous Next
  •  06-15-2008, 4:58 PM 43164

    xml and CR LF

    hi,

     i tried to parse xml file like :

    <northwind>
      <Customers CustomerID="AAAAA">
        <CompanyName>BXSW</CompanyName>
      </Customers>
      <Customers CustomerID="ADVCA">
        <CompanyName>AdventureWorks Cafe</CompanyName>
      </Customers>
      <Customers CustomerID="ALFKI">
        <CompanyName>Alfreds Futterkiste</CompanyName>
      </Customers>
     </northwind>

     i want all "Customers" and their content, so i tried this :

    <Customers\b[^>]*>(.*?)</Customers>
     

    But, in appareance, the new line, carriage return and spaces make wrong result (because the same regex with xml file in one line works)

    So, how include and fixe my expression to include this special caracters ?

     

     I hope it's comprehensive (newbie in regular expression and english expression it's so strong Stick out tongue),

    thanks for your reply
     

    Filed under: ,
  •  06-15-2008, 7:38 PM 43171 in reply to 43164

    Re: xml and CR LF

    What app/lang are you using this regex in?

    Either replace . with [\S\s] or enable the regex singleline option in your app/lang.


  •  06-16-2008, 2:28 AM 43179 in reply to 43164

    Re: xml and CR LF

    If you are parsing XML you should use Xpath instead of a regex.

    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
View as RSS news feed in XML