PHPAnalysis.Parsing.FileParser.ParsePHPFile C# (CSharp) Method

ParsePHPFile() public method

public ParsePHPFile ( string pathToFile ) : XmlDocument
pathToFile string
return System.Xml.XmlDocument
        public XmlDocument ParsePHPFile(string pathToFile)
        {
            Preconditions.NotNull(pathToFile, "pathToFile");

            var xmlDocument = new XmlDocument();

            var process = CreateParseProcess(pathToFile);
            process.Start();

            string tmp;
            var finalOutput = new StringBuilder ();
            while ((tmp = process.StandardOutput.ReadLine ()) != null)
            {
                tmp = XmlHelper.ReplaceIllegalXmlCharacters(tmp);
                finalOutput.AppendLine (tmp);
            }
            xmlDocument.LoadXml(finalOutput.ToString());
            return xmlDocument;
        }

Usage Example

Example #1
0
        public ParseResult ParseProjectFiles()
        {
            IEnumerable <string> files = Directory.GetFiles(ProjectPath, "*", SearchOption.AllDirectories)
                                         .Where(file => PHPSettings.PHPFileExtensions.Contains(Path.GetExtension(file)))
                                         .Select(file => file.Replace(@"\\", @"\"));

            var result = new ParseResult();

            var phpFileParser = new FileParser(PHPSettings.PHPParserPath);

            var progrssIndicator = ProgressIndicatorFactory.CreateProgressIndicator(files.Count());

            foreach (var file in files)
            {
                progrssIndicator.Step();
                try
                {
                    XmlDocument parseResult = phpFileParser.ParsePHPFile(file);
                    result.ParsedFiles.Add(file, parseResult);
                }
                catch (XmlException)
                {
                    result.FilesThatFailedToParse.Add(file);
                }
            }
            return(result);
        }
All Usage Examples Of PHPAnalysis.Parsing.FileParser::ParsePHPFile