Is it possible to derive the file path from a php DOM XML object loaded from a file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ManWithNoName
    New Member
    • Aug 2007
    • 88

    Is it possible to derive the file path from a php DOM XML object loaded from a file?

    I was wondering if it is possible to derive the file path from a loaded dom xml object, for example:
    [PHP]
    $doc = new DOMDocument();
    $doc->load('/path/to/file.xml');

    foreach($doc->childNodes as $domXmlElement) {
    require '/dom_functions.p hp';
    doSomething($do mXmlElement); // from "dom_functions. php"
    }
    [/PHP]

    Is it possible to somehow get the file path from where $domXmlElement was loaded from? For example (in the "doSomethin g()" function)
    [PHP]
    $path=DomXmlDoc ($domXmlElement );
    echo $path; // prints "/path/to/file.xml"

    [/PHP]
  • ManWithNoName
    New Member
    • Aug 2007
    • 88

    #2
    I'm still hoping that there is an answer to this question. If anyone has an idea, please don't hesitate...

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      It appears that there are no members with that experience, I have not.

      But I will copy this thread to the XML forum. Maybe you have more luck there.

      Ronald

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        The best way to do this would be to keep the string '/path/to/file.xml' as a variable, and pass it forward.

        The DOM xml object simply does not carry this information, since it does not care whether it was loaded from string, file, or artificially assembled.

        Comment

        • ManWithNoName
          New Member
          • Aug 2007
          • 88

          #5
          Thanks for your replies and input!

          Thanks ronverdonk, but I'm afraid it probably works as jkmyoung states:

          "The DOM xml object simply does not carry this information, since it does not care whether it was loaded from string, file, or artificially assembled."

          I'll look to other ways to handle my problem, but thanks again!

          Comment

          Working...