public PhpString transformToXml(DOMDocument doc) { // writing to a StringWriter would result in forcing UTF-16 encoding using (MemoryStream stream = new MemoryStream()) { if (!TransformInternal(doc.XmlNode, stream)) { return(null); } return(new PhpString(stream.ToArray())); } }
//public override bool ToBoolean() //{ // return true; //} #endregion #region Transformation /// <summary> /// Import a stylesheet. /// </summary> /// <param name="doc">The imported style sheet passed as a <see cref="DOMDocument"/> object.</param> /// <returns><B>True</B> or <B>false</B>.</returns> public bool importStylesheet(DOMDocument doc) { try { Load(doc.XmlDocument); } catch (XsltException e) { PhpException.Throw(PhpError.Warning, e.Message); return(false); } return(true); }
public static DOMDocument loadHTML(Context ctx, string source) { var document = new DOMDocument(); if (document.loadHTML(ctx, source)) { return(document); } else { return(null); // FALSE } }
public static DOMDocument load(Context ctx, string fileName) { var document = new DOMDocument(); if (document.load(ctx, fileName)) { return(document); } else { return(null); // FALSE } }
/// <summary> /// Transforms the source node to an URI applying the stylesheet given by the /// <see cref="importStylesheet(DOMDocument)"/> method. /// </summary> /// <param name="ctx">The current runtime context.</param> /// <param name="doc">The document to transform.</param> /// <param name="uri">The destination URI.</param> /// <returns>Returns the number of bytes written or <B>false</B> if an error occurred.</returns> public PhpValue transformToUri(Context ctx, DOMDocument doc, string uri) { using (PhpStream stream = PhpStream.Open(ctx, uri, "wt")) { if (stream == null) { return(PhpValue.Create(false)); } if (!TransformInternal(doc.XmlNode, stream.RawStream)) { return(PhpValue.Create(false)); } // TODO: return(PhpValue.Create(stream.RawStream.CanSeek ? stream.RawStream.Position : 1)); } }
public void __construct(DOMDocument document) { var xmldoc = document.XmlDocument; if (xmldoc == null) { // invalid document provided throw new ArgumentException(nameof(document)); } var element = xmldoc.DocumentElement; this.XPathNavigator = (element != null) ? element.CreateNavigator() // regular XPathNavigator from the root : xmldoc.CreateNavigator(); // empty xml document! InitNamespaceManagers(document._isHtmlDocument); }
public void __construct(DOMDocument document) { this.XPathNavigator = document.XmlDocument.CreateNavigator(); InitNamespaceManagers(document._isHtmlDocument); }
public DOMXPath(DOMDocument document) { __construct(document); }