Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 913393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:33:01+00:00 2026-05-15T17:33:01+00:00

So I have an XML file (XML export of a MS Word file). What

  • 0

So I have an XML file (XML export of a MS Word file). What I am just trying to do is to replace these two lines:

<w:t>Meno:</w:t>

And:

<w:t>Priezvisko:</w:t>

This is a longer XML excerpt:

<w:p w:rsidR="00CF175F" w:rsidRDefault="00CF175F">
−
<w:r>
<w:t>Meno:</w:t>
</w:r>
</w:p>
−
<w:p w:rsidR="00CF175F" w:rsidRDefault="00CF175F">
−
<w:r>
<w:t>Priezvisko:</w:t>
</w:r>
</w:p>

I am doing it like this:

$xml = file_get_contents('file.xml');

$doc = new DOMDocument();
$doc->loadXML($xml);
$doc->preserveWhiteSpace = false;

$wts = $doc->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main','t');

foreach ($wts as $wt) {

 echo 1;

 //if ('Meno:' === substr($wt->nodevalue, 0, 5)) {
  //echo 1;
 //}

}

That script echoes nothing. Why does the getElementsByTagName not work? There are tens of w:t tags in the XML.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:33:02+00:00Added an answer on May 15, 2026 at 5:33 pm

    I don’t know php, but almost certainly the problem is that the xml DOM thinks that “w” refers to a namespace that you haven’t yet defined. Instead of searching for a “tag” called “w:t”, you need to search for a tag named “t” in the namespace that “w” refers to.

    For a better explanation of xml namespaces and how to declare them (using “xmlns” in your document, see here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xml file which I need to open with Microsoft Word 2007.
I have an XML file that reads like this <abc> <ab>value</ab> <aa>time</aa> <ac>money</ac> </abc>
I have an XML file that I'm trying to read from here , and
I have this xml file which has text init. i.e Hi my name is
I have a xml file file name is file.xml This is content <PAD_INFO> <ITEMS>
I have this XML file of size 2.8GB (Polish Wikipedia dump). I have to
I have some data that I export into an XML file and put in
I have extracted an XML file (using Export Test Suite functionality) in TestLink. The
I have a 2.4 MB XML file, an export from Microsoft Project (hey I'm
I have xml file with such structure: ... <outer> ... <inner/> ... </outer> ...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.