Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get docx comments #2525

Open
nujiakk opened this issue Dec 8, 2023 · 1 comment
Open

how to get docx comments #2525

nujiakk opened this issue Dec 8, 2023 · 1 comment

Comments

@nujiakk
Copy link

nujiakk commented Dec 8, 2023

How do I directly retrieve comments information from a DOCX document?

@Akashpaila
Copy link

#2525

You can use the PHP word library to retreive the commented information in the DOCX
or else you can also use DOM document to access the commented information

Try this DOM Document method
Load the DOCX file as the xml
$xml = file_get_contents("path to your docx");
$dom = new DOMDocument();
$dom->loadXML($xml, LIBXML_PARSEHUGE);

$xpath = new DOMXPath($dom);
$comments = $xpath->query("//w:comment");

foreach ($comments as $comment) {
$author = $comment->getElementsByTagName("w:author")->item(0)->nodeValue;
$date = $comment->getElementsByTagName("w:date")->item(0)->nodeValue;
$text = $comment->getElementsByTagName("w:t")->item(0)->nodeValue;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants