By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,483 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,483 IT Pros & Developers. It's quick & easy.

xmlns attributes are added automatically to nodes

P: 1
I'm new to xml and having an issue listed below:

I have a sample xml file:

<?xml version="1.0" encoding="utf-8"?>
<tt xml:lang="en" xmlns="" xmlns:tts=""
xmlns:ttp="" xmlns:ttm=""
ttp:profile="" ttp:frameRate="24"
ttp:frameRateMultiplier="1000 1001" ttp:dropMode="nonDrop" ttp:timeBase="smpte">
<style xml:id="style.default" tts:fontFamily="Arial" tts:fontSize="100%" tts:fontStyle="normal" tts:fontWeight="normal" tts:backgroundColor="transparent" tts:color="white" />
<region xml:id="" tts:displayAlign="after" tts:textAlign="center" tts:origin="10% 10%" tts:extent="80% 80%" />
<div xml:lang="en">
<p begin="00:03:14:09" xml:id="p62" end="00:03:16:23" region="" style="style.default">And that was it.<br />That was his story, right?</p>
<p begin="00:03:18:14" xml:id="p63" end="00:03:19:16" region="" style="style.default">
<span tts:fontStyle="italic">So now...</span>

Now I have a simple xpath : `//*[starts-with(name(),'d')]` so it selects all elements under the div tag.

The problem is when evaluating the expression against the xml, I get
`xmlns=""` in all `<p></p>` tags and also I get `xmlns:tts=""` in all `<span></span>` tags. Bewlo is a sample result of what is returned:

<p begin="00:00:34:23" xml:id="p2" end="00:00:36:00" region="" style="style.default" xmlns="">That was his story, right?</p>
<span tts:fontStyle="italic" xmlns:tts="">But there’s a woman there<br /> So now...</span>

so, is there is something wrong in the xml structure itself?

when adding prefix to `xmlns=""` I do not get it in `<p></p>` tags but still getting xmlns in the `<span></span>` tags.

I appreciate if someone can help me out with this. Thanks in advance
Nov 10 '17 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,035
Which tools are you using to do this?
When viewing your XML with Notepad++, and using the XML-plugin, the Xpath seems to result in what you expect
Attached Images
File Type: jpg xpath.jpg (64.5 KB, 43 views)
Jan 6 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.